. NET provides us with a lot of verification controls, to some extent reducedProgramDevelopers work on development, but sometimes we often need to customize some of our own verification processes, rather than using the verification control provided in. net. Generally, verification is divided into client-side and server-side verification. The verification mentioned here refers to client-side verification.
The most common practice is to write a javsscript script by yourself, and return true or false based on whether the verification succeeds. Then, the Javascript script function is called when the server control is triggered by using controlid. Attribute ["Event"] = "javascript: functionname. But there is a problem when writing this, that is, when there are other pages on this page.. net, once the User-Defined script function is used to verify the control, the server will not verify the control.
That is, when controlid. if the attribute ["Event"] value is set to true, the compiler considers that it has passed all the verification, including..CodeSent to the server for execution. However, the. NET verification control has not been executed yet. However, as long as the code is slightly changed, after the custom verification is executed, the. NET verification control can still be executed.
Function validate ()
{
If (...) // if it passes Verification
{Return true ;}
Else
{Return false ;}
}
Then we add
Controlid. Attribute ["Event"] = "javascript: If (! Functionname () {return false ;}: "; if the custom verification fails, false is returned, and the control is not submitted to the server for execution. Otherwise, then proceed with the verification of other spaces on the page.
Sometimes reverse thinking is often ineffective.