views:

599

answers:

1

I have a simple textbox with a required field validation control attached to end and then being displayed in a validation summary at that bottom of the page. Everything works great on it but the validation seems to fire on the page's initial load which obviously sets off the required validation and displays the error message.

How do I set this control to only validate after the form has been submitted?

+2  A: 

It sounds like you have code in your page load like this:

if (!Page.IsValid()) //...

What you really want is this:

if (Page.IsPostBack && !Page.IsValid()) //...
Joel Coehoorn
Good catch, Joel! That's most probably the reason.
Cerebrus