The function is to generate an image and save the text in the image to the session. The source code is downloaded.
Create An ASPX file to provide the verification code image. For example, validcode. aspx, add this event to pageload.
Protected void page_load (Object sender, eventargs E)
{
Session ["validcode"] = socansoft. validcode. createimage (4, socansoft. validcode. validtype. Numeric );
}
This page is the page that provides the image source. to test it, the front-end html
<Asp: Image id = "image1" runat = "server" imageurl = "/webbbs/validcode. aspx"/>
<Asp: textbox id = "textbox1" runat = "server"> </ASP: textbox>
<Asp: button id = "button1" runat = "server" onclick = "button#click" text = "button"/> </div>
Background code
Protected void button#click (Object sender, eventargs E)
{
Bool B = textbox1.text = session ["validcode"]. tostring ();
Response. Write (B. tostring ());
}