When using the ASP. NET button control, you often need to verify the client before submitting the page. If it fails, the page is not submitted.
Previously, we used the following method to do this:
< Script Language = Javascript event = Onclick For = Mybtn >
If (Is the Verification Successful ?)
Return True // Allow Page Submission
Else
Return False // Blocked Page Submission
</ Script >
However, this method has many restrictions, and sometimes it is not convenient to know the button ID. Therefore, you can also find the following method (ASP. NET 2.0)
<Asp: button... onclientclick = "Return myvalidation ()"/> (forgot whether ASP. NET 1.1 has the onclientclick attribute)
The myvalidation function continues to submit the page if true is returned. If false is returned, the page is not submitted.
In fact, the formal approach should be to use event. returnvalue = false to stop the submission, for example:
< Script Language = Javascript >
Function Beforesubmit ()
{
// If verification fails
Event. returnvalue = False
}
</ Script >