How to avoid double click on the button inside UpdatePanel
This explains how to avoid double click on the button inside Update panel. If we press the button on the UpdatePanel twice, it makes the call to the server twice which is not needed and also it degrades the performance.
Consider that we have a button on the UpdatePanel which is an AJAX Control. All the AJAX control makes a call to the server to process the java script coded for that control. If we press the button on the UpdatePanel twice, it makes the call to the server twice which is not needed and also it degrades the performance.
The following script disables the post back operation for the button after pressing once but just before it makes the call to the server.
Put the following script on the page after the ScriptManager.
<script type="text/javascript">
var postbackControl = null;
var parm = Sys.WebForms.PageRequestManager.getInstance();
parm.add_beginRequest(BeginRequestHandler);
parm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args)
{
postbackControl = args.get_postBackElement();
postbackControl.disabled = true;
}
function EndRequestHandler(sender, args)
{
postbackControl.disabled = false;
postbackControl = null;
}
</script>
Once the post back call is made to the server by pressing button once, then the post back control is disabled using the above code to avoid double click on the button inside UpdatePanel.
Hi,
This is very good way to avoit post back.
thanks for share.....