By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,978 Members | 1,467 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,978 IT Pros & Developers. It's quick & easy.

Problems with disabling ASP.NET controls using javascript

P: n/a
I have two different problems:

1. When the user has clicked on a button that is causing the browser
to post back to the server, it could take a little while for the new
page to show up. So in the mean time, I want to change the cursor to
an hourglass and disable all of the controls on the form using
javascript so the user can't do anything with any of the controls on
the page. But when I disable certain controls (e.g. text boxes, radio
buttons, etc.) then their value/state doesn't get saved after it posts
back.

2. When I disable a link (i.e. one created with a LinkButton control)
using javascript, it gets grayed out, but the user can still use it.
In other words, it looks disabled, but the user can still click on it
and the page goes to the link. On the other hand, if I disable a link
on the server side by setting the control's Enabled property to false,
then it ends up completely disabled like you would expect. I think the
reason that in this case it's competely disabled is that not only does
the html that is generated have disabled="disabled" in the tag, but
there is no href in the tag. If I try to change the href to '' with
javascript, it doesn't do the same thing.

Any ideas?
Thanks in advance.
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
1) browsers do not postback any disabled form controls. As you are setting
the controls disabled before the actual postback, this is why the values are
cleared. from the server's point of view, it looks like they were cleared.

2) as an anchor is not a form control, it does not support disabled. to
disable a link in client script, try the following:

document.getElementById('myLink').onclick = function(){ return false;};

this will cancel the link request.
-- bruce (sqlwork.com)
"john" <jo********@yahoo.com> wrote in message
news:29**************************@posting.google.c om...
I have two different problems:

1. When the user has clicked on a button that is causing the browser
to post back to the server, it could take a little while for the new
page to show up. So in the mean time, I want to change the cursor to
an hourglass and disable all of the controls on the form using
javascript so the user can't do anything with any of the controls on
the page. But when I disable certain controls (e.g. text boxes, radio
buttons, etc.) then their value/state doesn't get saved after it posts
back.

2. When I disable a link (i.e. one created with a LinkButton control)
using javascript, it gets grayed out, but the user can still use it.
In other words, it looks disabled, but the user can still click on it
and the page goes to the link. On the other hand, if I disable a link
on the server side by setting the control's Enabled property to false,
then it ends up completely disabled like you would expect. I think the
reason that in this case it's competely disabled is that not only does
the html that is generated have disabled="disabled" in the tag, but
there is no href in the tag. If I try to change the href to '' with
javascript, it doesn't do the same thing.

Any ideas?
Thanks in advance.

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.