Generally, we can set various verification controls on ASPX to check the input items of the form. However, this function is over after the JavaScript is disabled on the client.
ASP. NET will execute Page after the Page_Load event. validate () starts the server-side verification code of the verification control, and the verification result is placed in Page. isValid, so that we can use Page in subsequent code. isValid to determine whether all data is valid.
If we want to know whether illegal data exists in the Page_Load event, we need to first call Page. Validate () in the Page_Load event to check.
The following is a simple code for your reference only:
Code
// Before Page. Validate is executed
Protected void Page_Load (object sender, EventArgs e)
{
If (IsPostBack = true)
{
Page. Validate ();
If (Page. IsValid = true)
{// Verification Successful
DoSomeThing ();
}
Else
{// Verification Failed
Return;
}
}
}
// After Page. Validate has been executed
Protected void btnSave_Click (object sender, EventArgs e)
{
If (Page. IsValid = true)
{// Verification Successful
DoSomeThing ();
}
Else
{// Verification Failed
Return;
}
}