473,395 Members | 1,938 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,395 software developers and data experts.

Validation Breaks Postback (C#)

42
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 1676
nateraaaa
663 Expert 512MB
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
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 Expert 512MB
You have the AutoPostBack property of these controls set to true correct?

Nathan
Mar 5 '08 #4
spamguy
42
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 Expert 512MB
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
It's a mixture of RequiredFieldValidators and RegularExpressionValidators. Any fields with errors have red asterisks appear beside them; errors are listed in the ValidationSummary 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
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. ...
4
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...
5
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...
9
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......
0
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 -...
3
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
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...
2
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...
5
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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.