Sarah Collins Sarah Collins - 1 year ago 130
C# Question

Reset button c# and clear validation controls

I have a c# registration form , but i'm unable to use the reset button to achieve the objective I want. Upon clicking the reset button, the validators I have demand that I fill up ALL textboxes before I can reset the fields.

If a user were to fill up half of the form and use the reset fields, the reset button does not achieve the objective I want it to, as all textboxes have to be filled.

The codes I'm using are as follows:

protected void resetButton_Click(object sender, EventArgs e)

Answer Source

Since this looks like Asp.Net Web Forms, as opposed to MVC, On the aspx file where you set up the button, set the CausesValidation property to false. Link:


<asp:Button CausesValidation="False" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download