473,586 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validation Breaks Postback (C#)

42 New Member
Before I added validation features, I had a few controls that made use of postback: for example, click a checkbox to make Panel1 and subcontrols visible.

I've since added clientside and serverside validation and suddenly postback is broken. Only if 'Submit' is clicked does the form update with changes that should have occured automatically.

Page_Load() has nothing involving IsPostBack, so I have no idea what else could be breaking it.
Mar 5 '08 #1
6 1693
nateraaaa
663 Recognized Expert Contributor
Before I added validation features, I had a few controls that made use of postback: for example, click a checkbox to make Panel1 and subcontrols visible.

I've since added clientside and serverside validation and suddenly postback is broken. Only if 'Submit' is clicked does the form update with changes that should have occured automatically.

Page_Load() has nothing involving IsPostBack, so I have no idea what else could be breaking it.
Post the code for your page_load event and your checkChanged event. Maybe seeing the code will give us a better idea of what is going on. (Please surround your code with code tags).

thanks
Nathan
Mar 5 '08 #2
spamguy
42 New Member
Post the code for your page_load event and your checkChanged event. Maybe seeing the code will give us a better idea of what is going on. (Please surround your code with code tags).

thanks
Nathan
I normally supply code with my questions, but as I said, I didn't find anything of worth in Page_Load(), so I left it off. But you're welcome to it. As a bonus is a DropDownList also not responding to postback; it should enable a TextBox when 'Other' is chosen:

Expand|Select|Wrap|Line Numbers
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3.     // enable/disable secondary contact fields based on checkbox status
  4.     Panel1.Enabled = cbSecondaryContact.Checked;
  5. }
  6.  
  7. protected void cbSecondaryContact_CheckedChanged(object sender, EventArgs e)
  8. {
  9.     Panel1.Enabled = cbSecondaryContact.Checked;
  10. }
  11.  
  12. protected void ddlOrganisation_SelectedIndexChanged(object sender, EventArgs e)
  13. {
  14.     txtOther.Enabled = ddlOrganisation.SelectedValue == "Other" ? true : false;
  15. }
  16.  
Mar 5 '08 #3
nateraaaa
663 Recognized Expert Contributor
You have the AutoPostBack property of these controls set to true correct?

Nathan
Mar 5 '08 #4
spamguy
42 New Member
You have the AutoPostBack property of these controls set to true correct?

Nathan
Right. Since these controls were working as expected earlier, AutoPostBack was and still is set to true.
Mar 5 '08 #5
nateraaaa
663 Recognized Expert Contributor
Right. Since these controls were working as expected earlier, AutoPostBack was and still is set to true.
What kind of validation are you doing? Are you using any required field validators or any other .NET validation controls? How are you displaying the validation to the user?

Nathan
Mar 6 '08 #6
spamguy
42 New Member
It's a mixture of RequiredFieldVa lidators and RegularExpressi onValidators. Any fields with errors have red asterisks appear beside them; errors are listed in the ValidationSumma ry up top:

Expand|Select|Wrap|Line Numbers
  1. <form id="form1" method="POST" action="" runat="server">
  2.         <div style="width:100%">
  3.             <asp:ValidationSummary ID="ValidationSummary1" CssClass="errorMessage" runat="server" ForeColor="Black" /><br />
  4.             <asp:Panel ID="noHTMLPanel" runat="server" CssClass="errorMessage" Visible="false">HTML tags are not permitted in the form submission.</asp:Panel>
  5.         </div>
  6.         <p>
  7.             <label for="txtFirstName">First Name: </label>
  8.             <asp:TextBox ID="txtFirstName" Width="225px" runat="server"></asp:TextBox>
  9.             <asp:RequiredFieldValidator ID="vdFirstName" runat="server" ControlToValidate="txtFirstName" ErrorMessage="&quot;First Name&quot; is required." Text="*" />
  10.             <br />
  11.  
  12.             <label for="txtLastName">Last Name: </label>
  13.             <asp:TextBox ID="txtLastName" Width="225px" runat="server"></asp:TextBox>
  14.             <asp:RequiredFieldValidator ID="vdLastName" runat="server" ControlToValidate="txtLastName" ErrorMessage="&quot;Last Name&quot; is required." Text="*" />
  15.             <br />
  16.  
  17.             <label for="txtEmail">Email Address: </label>
  18.             <asp:TextBox ID="txtEmail" Width="225px" runat="server"></asp:TextBox>
  19.             <asp:RequiredFieldValidator ID="vdEmail" runat="server" ControlToValidate="txtEmail" ErrorMessage="&quot;Email&quot; is required." Text="*" />
  20.             <asp:RegularExpressionValidator ID="vdREEmail" runat="server" ControlToValidate="txtEmail" Text="*" ErrorMessage="The email address is not in a valid format." ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" />
  21.             <br />
  22.     </p>
  23.  
  24. <!-- and so on... -->
  25.  
Mar 6 '08 #7

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

Similar topics

4
2607
by: Tim Meagher | last post by:
I am trying to use both validation controls and to add submit button attributes, but when I add the button attributes, the javascript fpr the validation controls is no longer created for the page. How can I use both? Thank you, Tim Meagher
4
4214
by: AIM48 | last post by:
Hi. We have a framework that we work with for our project. So far we have had very good success – basically the frame work wraps many day to day tasks so that they are all included in the project. The framework is built on a modified Page Controller pattern in which a aspx page controls the loading of clients (user controls) into a...
5
2409
by: M | last post by:
Hi, it's possible to append a custom action to a client-side verification of a validation control ? I have a validator summary control that shows (automatically) a message box if the validation of the validators in the page fails; after the user close this message box I have to perform a client-side function (hiding some text) ... it's...
9
3172
by: Bill Long | last post by:
I have a control that simply displays a list of links. Following one of the links doesn't post back or redirect to another page, it simply hides the current panel and shows the one you selected... So the behavour is similar to a tab control. The user is expected to fill out required data on each of the panels before pressing a submit button...
0
1700
by: dhurwitz | last post by:
Hi, In my ASP.NET 2.0 web app, I have a user control, ucBinEdges, with several text boxes. The user control has several validation controls validating the Text of these text boxes - CompareValidator, RangeValidator, RequiredFieldValidator, and a ValidationSummary. The page using ucBinEdges is a content page working in conjunction with a...
3
2751
by: teo | last post by:
Mozilla error on postback and validation ----------- A Button causes a Listbox to desappear. If no item has been selected on the Listbox, all is OK. If one or more items are selected,
0
1080
by: eurorscg | last post by:
Hi, i have this dropdownlist that breaks xhtml w3c validation.because it generates a select tag with a javascript property. this only happens when autopostback is set to true. so the the validation error that i get is this: # Error Line 263 column 86: there is no attribute "language".
2
1588
by: william.oram | last post by:
I have a few controls on a basic form I'm working on that make use of postback: for example, click a checkbox to make Panel1 and its subcontrols visible. I've since added clientside and serverside validation and suddenly postback is broken. Only if 'Submit' is clicked does the form update with changes that should have occured automatically....
5
2619
by: da | last post by:
I've inherited an ASP.net 2.0 (VB.net) application that uses a lot of GridViews and DetailsViews. I've ran into an odd issue with validation. We've added some validators to the INSERT template to validate a field. They include a required field validator, a Regex validator checking the length of the field, and a custom validator. Each is...
0
7912
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7959
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6614
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.