I'm a beginner in ASP.NET. just want to ask when we check if any validation fails, we do:
if (Page.IsValid)
{
...
}
can we do:
if (IsValid)
{
...
}
are they the same?
I'm a beginner in ASP.NET. just want to ask when we check if any validation fails, we do:
if (Page.IsValid)
{
...
}
can we do:
if (IsValid)
{
...
}
are they the same?
Depends on the context, i.e. where the code is.
Whenever you call a property without specifying the object it belongs to, this
is implied. So for example, this:
if (IsValid)
...is the same as this:
if (this.IsValid)
If the code exists within a page, then you this.IsValid
is calling the IsValid
property of the current page object. Which would make it the same.