473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Problems with disabling ASP.NET controls using javascript

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
1 1617
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: nick4soup | last post by:
General advice wanted: Some web sites (including two large companies in Australia) get themselves awfully confused if the user presses the BACK button in their browser (and possibly the forward...
6
by: ML.Steve | last post by:
Hi, There are lots of posts on this subject but after a couple of hours of going though them I still can't get a number of fields to be disabled when a checkbox is ticked. Basically I have a...
2
by: Jeelz | last post by:
Hi Guyz, Would appriciate any tip on disabling an ASP.NET LinkButton using client sided code like javascript. My Requirement is such that the user should be allowed to click on the link...
1
by: john | last post by:
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...
7
by: John Meyer | last post by:
I have a program where I have to enable or disable a list box based upon a radio button. Is there an "enabled" property on select boxes?
11
by: EagleRed | last post by:
I am writing an ASP.NET 2.0 application that uses master pages. I have some pages that must not be cached on the client. In ASP.NET 1.1 I achieved this using metatags: <meta...
3
by: ChrisN | last post by:
Invoking a postback before a large ASP.NET page has fully rendered will often cause the page to crash. This is unhelpful and confusing to users. I'm wondering if I can overcome this by...
0
by: rakhee | last post by:
Hello, I am using 2 div tags on my aspx form. I am making each one enabled and disabled using javascript based on some conditions. This is working fine. But when i disable the div tag, even though...
2
Frinavale
by: Frinavale | last post by:
I've run into a bit of a problem concerning JavaScript and ASP.NET. Upon page submission I disable all of my buttons and would also like to disable all of my inputs (Textboxes, DropDownLists, etc)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.