.NET避免重复提交的解决方案

来源:互联网 发布:web安全书籍推荐 知乎 编辑:程序博客网 时间:2024/06/05 03:28

在客户端写脚本,在提交的过程中让提交按钮变为不可用,并显示正在提交数据的提示

<script language="javascript" event="onclick" for="btnQuery">
document.all['txtKey'].disabled=true;
document.all['rblComp'].disabled=true;
document.all['btnQuery'].disabled=true;
document.all['btnQuery'].innerText="Please wait...";
</script>

当执行完毕后回复提交按钮的可用

rbTotal.Attributes.Add("onclick",
"document.getElementById('txtKey').disabled = true;" +
"document.getElementById('rblComp').disabled = true;"+
"document.getElementById('btnQuery').disabled = true;");