You only need to compare the value of the obtained text box with the value of "Session [" valicode.
// Create a bitmap object
Bitmap NewbitMap = new Bitmap (90, 22, PixelFormat. Format32bppArgb );
// Create a drawing surface based on the position object created above
Graphics g = Graphics. FromImage (NewbitMap );
// Fill the rectangle with the specified color
G. FillRectangle (new SolidBrush (Color. White), new Rectangle (0, 0, 90, 22 ));
// Create a font object
Font newfont = new Font ("", 14 );
// Create a RectangleF structure to specify a region
RectangleF rectangle = new RectangleF (0, 0, 90, 22 );
// Create a random number
Random Newrd = new Random ();
String [] abcd = "I, yes, no, high, day, earth, chat, material, basin, turbidity, small, small, tip, owe, pig, left, leg, knife, eat, thirst, stick, skin, shadow, rest, grass, camp, save, tax, say, bad, pass, illness, second, world, period, spring, quarter, get, penalty, thing, police, strong, nest, dish, dry, what, front, all, cry, pull, face, fish, text, ghost, or, hot, dog, egg, hair, pen, net, piece, structure, test, club, help, resistance, burn, stick, apple, shoes, board, sheet, flower, sea, question,, e, f, r, 9, 0, k, 2, 4, 7, 1, 3, q, w, y, u, v, x, p, s, a, d, 8, 5, t ". split (',');
Int RamStr = Newrd. Next (1,100 );
Int Ramstr1 = Newrd. Next (1,100 );
Int Ramstr2 = Newrd. Next (1,100 );
Int Ramstr3 = Newrd. Next (1,100 );
String ValiNum = abcd [RamStr] + abcd [Ramstr1] + abcd [Ramstr2] + abcd [Ramstr3]. ToString ();
Session ["valicode"] = ValiNum. ToString ();
// Fill the area of the rectangle specified by the RectangleF structure with the specified color
G. FillRectangle (new SolidBrush (Color. BurlyWood), rectangle );
// Draw random lines
For (int ii = 0; ii <10; ii ++)
{
Int x1 = Newrd. Next (NewbitMap. Height );
Int y1 = Newrd. Next (NewbitMap. Width );
Int x2 = Newrd. Next (NewbitMap. Height );
Int y2 = Newrd. Next (NewbitMap. Width );
G. DrawLine (new Pen (Color. Azure), x1, y2, y1, x1 );
}
// Fill in the rectangle filled above with the random number generated above
G. DrawString (ValiNum, newfont, new SolidBrush (Color. Blue), rectangle );
For (int I = 0; I <50; I ++)
{
Int x = Newrd. Next (NewbitMap. Width );
Int y = Newrd. Next (NewbitMap. Height );
NewbitMap. SetPixel (x, y, Color. FromArgb (Newrd. Next ()));
}
MemoryStream MS = new MemoryStream ();
NewbitMap. Save (MS, ImageFormat. Gif );
Response. ClearContent ();
Response. ContentType = "image/Gif ";
Response. BinaryWrite (ms. ToArray ());