Disable an ASP.NET form on the client before PostBack

  • Thread starter Christopher D. Wiederspan
  • Start date
C

Christopher D. Wiederspan

I'm wondering if there's a way to use javascript to disable a ASP.NET web
page before it starts to postback. Specifically, here's what I'm running
into. I've got a webform that has an autopostback dropdown box, and a couple
of textboxes just below it. When the user selects an option from the
dropdown, it triggers a postback event, which in-turn slightly adjusts the
remainder of the page.

The problem is that if the user is on a slow dial-up connection, they have
time to tab down below and start filling in the textboxes before the
postback mechanism kicks in and submits the form to the server. From the
user perspective, they've selected a value from the dropdown and now they
are typing along in the textbox, and all of the sudden the page posts back.

What I would like to do is add "document.body.disabled = true;" that will
execute immediately when the postback mechanism is started. I can get this
idea working great when the postback is caused by something like a button
and I use the RegisterOnSubmitStatement method of the page class, but the
AutoPostBack feature of the dropdown list bypasses the client-side onsubmit
event (this is a know/intended "issue").

What I'm wondering if there is a way to influence the output of the
__doPostBack script that my page is rendering out? Ideally, I could just add
my disable script right there in the beginning of that script and everything
would work great.

If anybody has any ideas on this, please let me know.

Thanks,
Chris
 
A

Alvin Bruney

a cleaner way is to just hide the button on the click event using attributes
or client side script. Anyone will do. That way as soon as you click, the
text boxes are gone so users cannot use the textboxes since they aren't
there. Or you can disable them as well.

DropdownList1.Attributes.Add("onclick","document.all.textbox1.style.display=
''");

roughly
 

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,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top