Thursday, April 14, 2011

Required Field Validator, displaying on initial page load

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?

From stackoverflow
  • 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()) //...
    
    Cerebrus : Good catch, Joel! That's most probably the reason.

0 comments:

Post a Comment