62,238
社区成员




protected void Page_Load(object sender, EventArgs e)
{
VaildImg v = new VaildImg();
//长度
v.Length = 6;
//字体大小
v.FontSize = this.fontSize;
v.Chaos = true;
v.BackgroundColor = this.backgroundColor;
v.ChaosColor = this.chaosColor;
v.CodeSerial = this.codeSerial;
v.Colors = this.colors;
v.Fonts = this.fonts;
v.Padding = this.padding;
//随机生成5位长度字符串
string code = v.CreateVerifyCode(); //取随机码
v.CreateImageOnPage(code, this.Context); // 输出图片
Session["VaildCode"] = code;// 使用Cookies取验证码的值
Response.End();
}
<asp:Image ID="imgValidate" runat="server" ImageUrl="~/Page/ValidateCode/VaildImg.aspx" onclick="this.src=this.src+'?'" />