CameTooFar

A Nerd's False Positive.

Regular expression validator firing after postback in asp.net


As usual, I’s really surprised to see what had happened when I attach a regular expression validator to one of my fileupload control. The regular expression validator was firing after every successful fileupload. Yup! The solution is way too simple. Simply, set the IsValid property of the regular expression validator to true.

protected void btnAddDocument_Click(object sender, EventArgs e)
{
    //
    // your logic comes here
    //
 
    regexvalUploadDoc.IsValid = true;
}

That’s it.