国产探花免费观看_亚洲丰满少妇自慰呻吟_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 = "";
}

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 碌曲县| 合江县| 冕宁县| 清远市| 麦盖提县| 温宿县| 鄂伦春自治旗| 滨海县| 安西县| 梁河县| 乐至县| 沙湾县| 隆安县| 涡阳县| 汉川市| 石门县| 江永县| 永嘉县| 正宁县| 泊头市| 临高县| 容城县| 石楼县| 淮安市| 纳雍县| 萨迦县| 礼泉县| 承德市| 延川县| 巢湖市| 灌南县| 安龙县| 凤城市| 玛多县| 龙山县| 正宁县| 泽普县| 荔波县| 炉霍县| 正宁县| 随州市|