Asp.net| Verification Code
A class that implements a validation code #region
public class Validatecode
{
Private Bitmap validateimage;
Private Graphics G;
Public Validatecode ()
{
Validateimage = new Bitmap (PIXELFORMAT.FORMAT24BPPRGB);
g = Graphics.fromimage (validateimage);
}
public void Drawvalidatecode (Page e, string i)
{
g.DrawString (i, New Font ("boldface", 16,fontstyle.bold), New SolidBrush (Color.White), New PointF (2,4));
G.fillrectangle (New LinearGradientBrush (0,0), new Point (120,30), Color.FromArgb (0,0,0,0), Color.FromArgb ( 255,255,255,255)), 0,0,120,30);
Validateimage. Save (E.outputstream, imageformat.jpeg);
G.save ();
MemoryStream ms=new MemoryStream ();
Validateimage. Save (ms,system.drawing.imaging.imageformat.gif);
E.response.clearcontent ();
E.response.contenttype= "Image/gif";
E.response.binarywrite (Ms. ToArray ());
E.response.end ();
Validateimage. Save (E.mappath ("Numimage/validateimage.gif"), imageformat.gif);
E.end ();
}
}
#endregion
private void Makevalidatecode ()
{
Char[] s = new char[]{' 0 ', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' a '
, ' B ', ' C ', ' d ', ' e ', ' f ', ' g ', ' h ', ' I ', ' j ', ' K ', ' l ', ' m ', ' n ', ' o ', ' P ', ' Q '
, ' R ', ' s ', ' t ', ' u ', ' V ', ' w ', ' x ', ' y ', ' z ', ' A ', ' B ', ' C ', ' D ', ' E ', ' F ', ' G '
, ' H ', ' I ', ' J ', ' K ', ' L ', ' M ', ' N ', ' O ', ' P ', ' Q ', ' R ', ' S ', ' T ', ' U ', ' V ', ' W '
, ' X ', ' Y ', ' Z '};
String num = "";
Random r = new Random ();
for (int i = 0; i < 5; i++)
{
num + + s[r.next (0, S.length)]. ToString ();
}
((loginuserinfo) session["Loginuserinfo"]). Validatenum = num;
TextBox3.Text = "";
}
Also synthesizes a part of the code of others. :)