码迷,mamicode.com
首页 > 编程语言 > 详细

验证码的全部代码(注意两种JavaScript的写法)

时间:2018-04-16 16:14:55      阅读:304      评论:0      收藏:0      [点我收藏+]

标签:ssr   poi   tput   nstat   html   save   javascrip   pac   char   

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="js/jquery-1.5.2.js"></script>
<script type="text/javascript">
$(function () {
$("#yanzenma").click(function () {
var img = document.getElementById("yanzenma");
img.src = "yanzenma.ashx?" + new Date();
});
});
</script>
</head>
<body>
<img src="yanzenma.ashx" id="yanzenma" />
</body>
</html>

 

 

 

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="js/jquery-1.5.2.js"></script>
<script type="text/javascript">
var GenXin = function () {
var img = document.getElementById("yanzenma");
img.src = "yanzenma.ashx?" + new Date();
};
</script>
</head>
<body>
<img src="yanzenma.ashx" id="yanzenma" onclick="GenXin()"/>
</body>
</html>

 

 

 

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Web;
using System.Web.SessionState;

namespace lianxi03
{
/// <summary>
/// yanzenma 的摘要说明
/// </summary>
public class yanzenma : IHttpHandler,IRequiresSessionState
{

public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "image/jpeg";
Random r = new Random();
int a = r.Next(1000,10000);
context.Session["yanzenma"] = a;
using (Bitmap bmp = new Bitmap(50, 25))
{
using (Graphics g = Graphics.FromImage(bmp))
using (Font font = new Font(FontFamily.GenericSerif, 15))
{
g.DrawString(a.ToString(), font, Brushes.Red, new PointF(0, 0));
}
bmp.Save(context.Response.OutputStream, ImageFormat.Jpeg);
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}

验证码的全部代码(注意两种JavaScript的写法)

标签:ssr   poi   tput   nstat   html   save   javascrip   pac   char   

原文地址:https://www.cnblogs.com/lijian0755/p/8856031.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!