欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【防止ASP.NET按钮多次提交的办法】,下面是详细的分享!
防止ASP.NET按钮多次提交的办法
<head runat="server">
<title>禁止多次提交网页测试</title>
<style type="text/css">
.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("Button2").className ="disable";
document.getElementById("Button2").value='正在提交.';
document.getElementById("Button2").onclick=Function("return false;");
return true;
}
document.onkeydown=mykeydown;
function mykeydown()
{
if(event.keyCode==116) //屏蔽F5刷新键
{
window.event.keyCode=0;
return false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
输入一些内容<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:ListBox ID="ListBox1" runat="server" Height="77px" Width="332px">
</asp:ListBox><br />
<asp:Button ID="Button2" runat="server" Text="OK" Width="77px"
onclick="Button2_Click" />
</div>
</form>
</body>
</html>
以上所分享的是关于防止ASP.NET按钮多次提交的办法,下面是编辑为你推荐的有价值的用户互动:
相关问题:ASP.Net中防止页面刷新重复提交的几种方法
答:a.使用服务器端的 Response.Redirect("YourPage");b.使用客户端脚本 location.href='yourPage';这两种方法的缺点是如果要保留页面数据不太方便,如果不用保留可以采用。 2、操作完毕设置一个Session,进入页面时判断这个Session是否为null,如果... >>详细
相关问题:asp.net怎么防止按钮连续点击? ASP.NET
答::function checkText(){ var vT=document.getElementById("txtNR"); if(vT.value.length>50){ alert("输入的内容不得超过50个字!"); return false; } else { document.getElementById("btnSub").disabled = true... >>详细
相关问题:asp.net button 接连单击两次,连续触发两次事件,...
答:这里之能通过客户端js代码控制,点击的时候将按钮状态设置为关闭, 如果这样的按钮用的比较多,可以通过继承button自定义封装一个防止二次点击的按钮, 很早以前写过这东西,很简单网上可以找到资料, 效果就是点下按钮会变灰并显示“正在提交”之... >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
