Link to home
Start Free TrialLog in
Avatar of rhinoceros
rhinoceros

asked on

Miss the RequiredFieldValidator checking

Syntax

The RequiredFieldValidator will check when I submit a form by "Submit" button. But if I click "Cancel" button, which also warning me by RequiredFieldValidator cheeking. So how to miss this checking when I click "Cancel" button.


<asp:TextBox id="Code" runat="server" MaxLength="13"></asp:TextBox>
<input type="submit" value="Submit" name="submit" runat="server" onserverclick="OnSubmit" />
<input type="submit" value="Cancel" name="cancel" runat="server" onserverclick="Cancel_Click" />
<asp:RequiredFieldValidator id="RequiredFieldValidator" runat="server" ErrorMessage="No Code" ControlToValidate="Code" ForeColor="White"></asp:RequiredFieldValidator>

Thanks !
ASKER CERTIFIED SOLUTION
Avatar of mmarinov
mmarinov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it is the "causesvalidation" property that decided whether the page validation has to executed or not  .. by default it is true for all server controls .. so by setting it to false for a particular .. the validation scripts will not be run on the client side for just that control ..

pls note, i just elborated on what mmarinov had already mentioned in the above example ...
Avatar of rhinoceros
rhinoceros

ASKER

Rejojohny

Thanks for your comment indeed

But I need to miss the validation when I click "Cancel" button. (to do something such as "Redirect"). I can do it as I think, so mmarinov's answer is good me.


Thanks again!