http://www.chinabs.net/aspnet/default.asp?infoid=390
解决方案 »
- 弹出对话框问题
- net 怎样 1.将web用户控件做成.dll 2.再调用
- AjaxToolKit的TargetControlID能不能动态指定
- asp.net2.0(C#)做一个留言板,怎么限制没有登录的人,使得未登录用户可以浏览,不可以添加留言?
- ocx如何打包成cap包,以供用户下载安装使用
- window.open 刷新父页面
- 高手进来看看,这段<script>代码是循环滚动的,怎么让鼠标放上去停止滚动呢?
- 新手。。再请教.net是否也有像asp中的Rs.AddNew
- 兄弟门啊,推荐一下你们所用的开发工具啊?都是Microsoft Visual Studio .NET 吗?哪个版本好啊???
- ASP.NET 中 如何实现 Socket 通讯
- INSERT INTO 语句的语法错误
- [求助]ImageButton想做弹出提示框并跳转到相应的页面
分是大家快乐的源泉,是动力!
public class ValidateCode
{
private Bitmap validateimage;
private Graphics g;
public ValidateCode()
{
validateimage = new Bitmap(120, 30, PixelFormat.Format24bppRgb);
g = Graphics.FromImage(validateimage);
}public void DrawValidateCode(Page e, string i)
{
g.DrawString(i, new Font("黑体",16,FontStyle.Bold),new SolidBrush(Color.White),new PointF(2,4));
g.FillRectangle(new LinearGradientBrush(new Point(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 = "";
}