Question

There is a strange problem in my application. There is one mandatory field which we are making mandatory through Required field validator but still in few scenarios it fails. Can someone tell me what can be the possible causes. I am not able to recreate this issue.

Was it helpful?

Solution

If someone disables JavaScript, and you're not using Page.IsValid in your server side code, then you might encounter empty fields.

This should do:

void SubmitButton_Click(object sender, EventArgs e)
{
    if (!Page.IsValid)
        return;

    // Do form stuff
}

OTHER TIPS

If you are trying to validate a dropdownlist with a "Please select" option, with a value of "-1" for example, you will need to set the initial value property of the validation control to this value to ensure that another choice has been made.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top