473,396 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem with Button that always causes validation in ASP.NET

2
Ok, for any button I add to the aspx page directly, if I juste set their CausesValidation property to false and it doesn't cause validation.

For a button or imagebutton added programatically in C#, I'd go:
Expand|Select|Wrap|Line Numbers
  1. ImageButton im = new ImageButton();
  2. im.ImageUrl = "~/images/"+p_row.ItemArray[2].ToString();
  3. im.CausesValidation = false;
  4. im.Click += new ImageClickEventHandler(im_Click);
  5. tc.Controls.Add(im);
The requiredfieldvalidator doesn't seem to acknowledge this at all and still pops up every time I click on my imageButton/Button. Is there anything else I need to do to stop a button added in C# from causing validation ?

Note: The validator is on the masterpage and the button in a ContentPlaceHolder; I don't think it matters at all but just in case.
Nov 30 '07 #1
1 2466
naju
2
Found the problem. The image button was not instanciated on postback, only on first view. However, it's still weird that the validator is triggered in such a case, when the button doesn't even exist anymore after being clicked (how could it cause validation?). Oh well.
Dec 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Marc Llenas | last post by:
Hi there, I'm stuck on a validation function for a form and I cannot figure out what the problem is. The page is in ASP. Any ideas? The function being called is: <script...
4
by: Elliot M. Rodriguez | last post by:
I have a Delete button in my datagrid. I'm attempting to add some code confirming whether the user wishes to really delete the item or not. The confirm pops up, but I cannot suppress the...
5
by: Tina | last post by:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing validation elsewhere on the page. I want to specify that these buttons should not cause validation but they have no design...
2
by: Tim Frawley | last post by:
Source code attached indicates my problem with validation and a button bar save button. Fill the Textbox with some text then tab off the control. The message box will display the text in the...
10
by: michele | last post by:
I have a problem with VB.Net and IsNumeric() function because it always returns FALSE even the string can be a number. There is another strange thing, the same program (it is a test) runs good on...
1
by: Alexander Widera | last post by:
hi, i have 2 custom webcontrols on one page ... both have buttons (of the class Button) on it with different Click or Command Events. But the problem is, that a click on the button in the second...
2
by: Pawel Pabich | last post by:
Hi, I have very simple code: <asp:TextBox ID="TextBox1" runat="server"/> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"...
21
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on...
8
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I the page knows there was a cross post back. but i can not find the control. (asp.net 3.5) calling page has a master calling control: <asp:Button ID="btnSendAlert" runat="server" Text="Go"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.