I. Verification Code Generation
When I was developing a. Net webpage, I found that when I used the verification code, I provided a way to "not see clearly, change one". I am also a mediocre person, so I also set it like this:
1. Number. aspx indicates the verification code generation.Code.
2. Refresh () is the image switching function.
In this example, "document. all. check. src = ''" simply uses check. the "src" reconfiguration does not support image update and verification code re-generation. Later, through a variety of experiments, we found that the parameter configuration transfer can be sent to 1. the ASPX page is called again.
Use. Net to generate random numbers. When you click "Pass Parameter" to refresh the image, the page is re-activated:
Function refresh (){
VaR num = math. Ceil (math. Random () * 100 );
Document. All. Check. src = "./number. aspx? Num = "+ num;
}
Click image update for the verification code.
2. Ajax obtains the session verification code information.
1. Call the following code in page_load.
Ajaxpro. Utility. registertypeforajax (typeof (Class));
2. The following configuration is required when the session is called.
[Ajaxpro. ajaxmethod (ajaxpro. httpsessionstaterequirement. Read)]
Public String Ajax ()
{
If (session ["Number"]! = NULL ){
Return session ["Number"]. tostring ();
} Else {
Return "";
}
}
3. Call the Ajax function in Js.
VaR num = ajaxspace.Class. Ajax (). value;