这二天一个小兄弟问到我这个,其实很简单,贴在这里备个份:
Code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="JsSafeCode._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function reloadcode() {
document.getElementById('imgCode').src = 'checkCode.aspx?' + Math.random();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtCode" runat="server" Width="80"></asp:TextBox><img src="checkCode.aspx"
id="imgCode" onclick="reloadcode()" alt="点击刷新验证码" style="cursor: pointer" />
<asp:Button ID="btnTest" runat="server" Text=" 验 证 " OnClick="btnTest_Click" />
</div>
</form>
</body>
</html>