Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page.IsValid always return false

Tags:

c#

asp.net

I have cause validation true on button. And I am checking the Page.IsValid in c# code. But its always returning false value?

like image 918
sathish Avatar asked Aug 17 '10 08:08

sathish


3 Answers

Here is a code snippet that helped me debug my issue:

foreach (BaseValidator validator in Page.Validators)
{
    if (validator.Enabled && !validator.IsValid)
    {
        // Put a breakpoint here
        string clientID = validator.ClientID;
    }
}
like image 191
kevinpo Avatar answered Oct 13 '22 00:10

kevinpo


I know it might be too late but: Did you have a hidden validator?

like image 40
Fabio Milheiro Avatar answered Oct 13 '22 00:10

Fabio Milheiro


I know its too late, Hope some one will benefit

If you have Requiredfieldvalidators in webpage, you need to set validataiongroup attribute to the each RequiredValidator.

And then in code you've to check

Page.Validate("validategroupname");
if(!Page.IsValid()){
 // your code
}

this solves issue

like image 25
praveenb Avatar answered Oct 13 '22 00:10

praveenb