防止用户重复提交数据
时间:2010-09-02 来源:szny
在项目中,需要从BPCS中取数据,查询的数据比较多,时间较长。
为了防止用户反复的点击按钮,于是我用了UpdateProgress,里面放了一个loading的图片,并提示用户等待。
<asp:UpdateProgress AssociatedUpdatePanelID="UpdatePanel1" ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div style="text-align: center; margin-top: 10px">
<img src="../Images/waiting.gif" style="text-align: center;" alt="Waiting" /><font
color="#6478dc" style="font-weight: bold; font-size: medium;"> please wait...</font></div>
</ProgressTemplate>
</asp:UpdateProgress>
然后禁用掉按钮:
<script type="text/javascript">
Sys.Application.add_init(App_Init);
function App_Init() {
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequest);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
}
function BeginRequest(sender, args) {
$('input[type=submit]').attr('disabled', true);
}
function EndRequest(sender, args) {
$('input[type=submit]').attr('disabled', false);
}
</script>
此段js放在ScriptManager之后,实际效果见下图:
相关阅读 更多 +
排行榜 更多 +











