473,386 Members | 1,598 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,386 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 1263
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...
4
by: Dan =o\) | last post by:
Hi guys, in the scenario where a user fills in a form, and clicks on a button to Save, there's a period of waiting (the slower the connection between client and server, the longer the delay)...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.