[Asp.Net]防止ASP.NET按钮多次提交的办法
2012-07-10 14:24
459 查看
当页面在提交时,若网速太慢,用户可能多次点击提交按钮。这样,导致向数据库中插入了多条相同的记录。
//方法一:在提交时调用一段客户端的代码。
function a()
{
document.getElementById("btnok").value = '正在提交
';
document.getElementById("btnok").onclick=function(){return false;};
return true;
}
<input id="btnok" runat="server" type="submit" value="确定" onclick="return a();"
onserverclick="Submit1_ServerClick" />
//方法二:必需要是Asp.net服务器控件。(注意UseSubmitBehavior属性)
<asp:Button ID="btnSumbit" runat="server" UseSubmitBehavior="false"
OnClientClick="this.value='正在提交
';this.disabled=true; "
Text="提交" OnClick="btnSumbit_Click" />
//方法一:在提交时调用一段客户端的代码。
function a()
{
document.getElementById("btnok").value = '正在提交
';
document.getElementById("btnok").onclick=function(){return false;};
return true;
}
<input id="btnok" runat="server" type="submit" value="确定" onclick="return a();"
onserverclick="Submit1_ServerClick" />
//方法二:必需要是Asp.net服务器控件。(注意UseSubmitBehavior属性)
<asp:Button ID="btnSumbit" runat="server" UseSubmitBehavior="false"
OnClientClick="this.value='正在提交
';this.disabled=true; "
Text="提交" OnClick="btnSumbit_Click" />
相关文章推荐
- 防止ASP.NET按钮多次提交的办法
- 【转帖】防止ASP.NET按钮多次提交的办法
- 防止ASP.NET按钮多次提交的办法
- 【ASP.NET】防止ASP.NET按钮多次提交的办法
- 防止ASP.NET按钮多次提交的办法
- 【ASP.NET】防止ASP.NET按钮多次提交的办法
- 防止ASP.NET按钮多次提交的办法
- 防止ASP.NET按钮多次提交的办法
- 防止ASP.NET按钮多次提交的办法及延伸
- 防止ASP.NET按钮多次提交的办法
- 防止ASP.NET按钮多次提交的办法
- [转帖]【ASP.NET】防止ASP.NET按钮多次提交的办法
- [Asp.Net]防止ASP.NET按钮多次提交的办法
- 防止ASP.NET按钮多次提交的办法
- 防止ASP.NET按钮多次提交的办法
- 防止ASP.NET按钮多次提交的办法 .
- 【ASP.NET】防止ASP.NET按钮多次提交的办法
- 防止ASP.NET按钮多次提交的办法(很好的。)
- 防止ASP.NET按钮多次提交的办法
- 防止ASP.NET按钮多次提交的办法