Disable web page controls during postback round-trip

G

Guest

Is there a way to disable all the controls the instant any auto-postback
controls are changed (resulting in a postback that takes a couple seconds),
so that the user can't continue changing other controls while the postback to
the server is running?

The reason this is necessary is because the user can be fooled into not
knowing that the browser has posted-back to the server (he doesn't see the
little blue progress bar at the bottom of IE), and he keeps clicking or
typing away... The form basically needs to be disabled until it is rebuilt
at the end of the postback.

Thanks!
 
K

Karl Seguin [MVP]

You should take a look at:
http://weblogs.asp.net/vga/archive/2004/03/01/NoMoreHijackingOfDoPostBackInWhidbey.aspx

once you've figured out how to tap into __dopostback, I would simply disable
controls on the page, or the form, or something have a javascript function
write into a value and then check if the value has been sent. So it would
look like:

var __oldDoPostBack = __doPostBack;
// replace __doPostBack with another function
__doPostBack = AlwaysFireBeforeFormSubmit;



var isSubmitting = false;

function AlwaysFireBeforeFormSubmit (eventTarget, eventArgument) {




if (!isSubmitting)

{

isSubmitting = true;

return __oldDoPostBack (eventTarget, eventArgument);

}

return;

}



that's just a quick example, it'll be different in 2.0 as the above article
explains..



Karl
 
A

Adrian Parker

I use the following..

Add the following javascript to the page:-

function ignoreinput() (
return false;
}
function stop_input() {
window.attachEvent(""onkeydown"", ignoreinput); " _
window.attachEvent(""onclick"", ignoreinput); " _
}

Then in the form element of the page add an onsubmit entry..

<form id="Form1" method="post" runat="server" onsubmit="stop_input();">

Only problem is that there's no visual indicator that input is currently disabled, so you could, in the stop_input function, change
something about the form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top