例子,在asp.net代码中禁止内容的重复提交。
1,html部分
<html>
<style>
.disable
{
border-style:none;
border-width: thin;
background-color:Transparent;
color: #CCCCCC;
cursor:wait;
}
</style>
<script type="text/javascript" language="javascript">
function DisableButton()
{
document.getElementById("Button1").className = "disable";
document.getElementById("Button1").value = '正在提交.请稍候!';
document.getElementById("Button1").onclick=Function("return false;");
return true;
}
document.onkeydown=mykeydown;
function mykeydown()
{
if(event.keyCode==116) //屏蔽F5刷新键,禁止重复提交
{
window.event.keyCode=0;
return false;
}
}
</script>
<body>
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" CssClass="button112" />
</form>
</body>
</html>
2,.CS文件