We had an ASP.NET page and user can select something in dropdown and press Submit button and depending on that some data is displayed in datagrid.
The issue is before even the data comes back the user selects some other value in dropdown and presses “Submit”, which we do not want.
We want to disable the mouse clicks of the user till the user gets the data for the first request.
for(var i=0; i<document.forms.elements.length; i++)
Submit the form only when the button is clicked for the first time and don’t submit it again when the form submission is in progress.
This can be achieved using the code as below:
//isFormSubmitted variable is used to prevent the form submission while the server execution is in progress
//If the form is already submitted, this function will return false preventing the form submission again.
isFormSubmitted = true;
This is the third way of disabling mouse clicks.
The “WaitCursor“ method converts the mouse of the page to “wait” state (hourglass) and disables all the controls (input, select & hyperlink).
<body onbeforeunload=”waitcursor();” onunload=”waitcursor();” onload=”registerEventHandler();” MS_POSITIONING=”GridLayout”>
<form id=”frmAgedInventory” method=”post” runat=”server”>
//Do this if Buttons and Link where click that do a heavy postback.
//Disables all the HyperLink Controls
//divResult.style.display = “none”;
//Register All the Buttons with an Event to Identify the Click event for required buttons
//This Function is used to set the Flag that required Buttons where Click