CopyCode The Code is as follows: using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Using system. drawing;
Using system. Drawing. drawing2d;
Public partial class _ default: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
Bitmap BMP = new Bitmap (50, 25 );
Graphics G = graphics. fromimage (BMP );
Solidbrush sb = new solidbrush (getcolor ());
G. drawstring (checknumber (), new font ("", 16), Sb, 0, 0 );
BMP. Save (response. outputstream, system. Drawing. imaging. imageformat. GIF );
}
Public static string checknumber ()
{
String checkcode = "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz ";
Int Len = 4;
String tmpstr = "";
Int irandnum;
Random RND = new random ();
For (INT I = 0; I <Len; I ++)
{
Irandnum = RND. Next (checkcode. Length );
Tmpstr + = checkcode [irandnum];
}
Return tmpstr;
}
Private color getcolor ()
{
Random r = new random ();
Return color. fromargb (R. Next (256), R. Next (256), R. Next (256 ));
}
}