国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net實現驗證碼

2024-07-10 13:06:26
字體:
來源:轉載
供稿:網友

#region 實現一個驗證碼的類

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 = "";
}

也綜合了別人的一部分代碼。:)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 呼和浩特市| 吉隆县| 尼勒克县| 北辰区| 蒙阴县| 郯城县| 固安县| 清镇市| 商水县| 新邵县| 淳化县| 新竹市| 汝州市| 兴城市| 正宁县| 花莲县| 鄯善县| 玛曲县| 曲松县| 迁西县| 西藏| 玉环县| 齐齐哈尔市| 绥芬河市| 霍山县| 房产| 水富县| 高青县| 襄汾县| 东源县| 谢通门县| 海盐县| 凌海市| 封丘县| 永德县| 寻乌县| 马关县| 平和县| 大厂| 霍山县| 高安市|