views:

2180

answers:

3

I have several RequiredFieldValidators in an ASP.NET 1.1 web application that are firing on the client side when I press the Cancel button, which has the CausesValidation attribute set to "False". How can I get this to stop?

I do not believe that Validation Groups are supported in 1.1.

Here's a code sample:

<asp:TextBox id="UsernameTextBox" runat="server"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="UsernameTextBoxRequiredfieldvalidator" ControlToValidate="UsernameTextBox" 
runat="server" ErrorMessage="This field is required."></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="UsernameTextBoxRegExValidator" runat="server" ControlToValidate="UsernameTextBox"
Display="Dynamic" ErrorMessage="Please specify a valid username (6 to 32 alphanumeric characters)." 
ValidationExpression="[0-9,a-z,A-Z, ]{6,32}"></asp:RegularExpressionValidator>

<asp:Button CssClass="btn" id="addUserButton" runat="server" Text="Add User"></asp:Button>
<asp:Button CssClass="btn" id="cancelButton" runat="server" Text="Cancel" CausesValidation="False"></asp:Button>

Update: There was some dynamic page generating going on in the code behind that must have been messing it up, because when I cleaned that up it started working. Thanks everyone.

Thanks Mark

A: 

Are they in separate validation groups (the button and validator controls)?

You're not manually calling the JS to do the client validation are you?

Slace
A: 

Without seeing your code (or at least a piece of it) no answer will be 100%. edit: thanks for the code sample!

Chuck
A: 

Validation Groups were not added to ASP.NET until version 2.0. This is a 1.1 question.

Double check your setting and make sure you are not overwriting it in the code behind.

dbugger