I have an asp .net page with many a few dozen buttons and dropdownlists that need to postback.
I found a nice bit of javascript code that will loop within all elements on a page that cause postback and disable them as soon as any element that can cause postback is triggered. This stops a user from getting click happy waiting for the postback to finish.
It works well but on complex pages is very slow as the loop has to scan thousands of elements.
Is there a way instead to ignore any postback request after the first, so even if a button or different buttons are pressed it simple ignores all requests after the first.
I found something that almost works.
It does the submit on 1 time to the server.
However, on the server side code behind doesn't know what was clicked.
Here's what I tried to do
On my masterpage:
<form id="form1" runat="server" onsubmit="return check_form()" >
The javascript for check_form() with some alerts.
<script language="JavaScript">
var submitted=false;
function check_form() {
if (submitted == true) {
alert ("form already submitted") ;
return false;
}
else {
submitted = true ;
alert ("form being submitted") ;
document.forms[0].submit();
}
}
I'm new to javascript so am not sure what I need to change to get it to postback and not loose what was doing the postback.
Thanks!!!
I found a nice bit of javascript code that will loop within all elements on a page that cause postback and disable them as soon as any element that can cause postback is triggered. This stops a user from getting click happy waiting for the postback to finish.
It works well but on complex pages is very slow as the loop has to scan thousands of elements.
Is there a way instead to ignore any postback request after the first, so even if a button or different buttons are pressed it simple ignores all requests after the first.
I found something that almost works.
It does the submit on 1 time to the server.
However, on the server side code behind doesn't know what was clicked.
Here's what I tried to do
On my masterpage:
<form id="form1" runat="server" onsubmit="return check_form()" >
The javascript for check_form() with some alerts.
<script language="JavaScript">
var submitted=false;
function check_form() {
if (submitted == true) {
alert ("form already submitted") ;
return false;
}
else {
submitted = true ;
alert ("form being submitted") ;
document.forms[0].submit();
}
}
I'm new to javascript so am not sure what I need to change to get it to postback and not loose what was doing the postback.
Thanks!!!