469,647 Members | 1,769 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,647 developers. It's quick & easy.

Javascript Disabling WebControls

Hello,
I have an ASP.Net web page populated with WebControls, such as
textboxes and checkboxes. On this page I also have a JavaScript that
disables these textboxes under certain events (such as "onLoad" and
"onClick") by calling the javascript method <object>.disabled =
<true/false>. This works visably fine on the webpage, however, when I
do a postback to the server and check the <WebControl>.Enabled
property on an item I disabled via the javascript it does not reflect
its current state. Rather, it reports the Enabled property as whatever
I initilized it to. Now I believe this is because the client is never
communicating the enabled/disabled state change to the server. Is
there a work around for this that doesn't require additional server
side postbacks and validation? The whole purpose of using JavaScript
in the first place was to avoid postbacks on checkbox clicks that
would call server-side code to enable/disable textboxes. Any ideas are
much appreciated.

- Harry
Nov 17 '05 #1
2 1241
You could populate hidden form fields on the client when you make a
client-side change to an object, so that when you handle the PostBack, you
can set the properties on the server side.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.

"Harry" <ro******@vu.union.edu> wrote in message
news:16**************************@posting.google.c om...
Hello,
I have an ASP.Net web page populated with WebControls, such as
textboxes and checkboxes. On this page I also have a JavaScript that
disables these textboxes under certain events (such as "onLoad" and
"onClick") by calling the javascript method <object>.disabled =
<true/false>. This works visably fine on the webpage, however, when I
do a postback to the server and check the <WebControl>.Enabled
property on an item I disabled via the javascript it does not reflect
its current state. Rather, it reports the Enabled property as whatever
I initilized it to. Now I believe this is because the client is never
communicating the enabled/disabled state change to the server. Is
there a work around for this that doesn't require additional server
side postbacks and validation? The whole purpose of using JavaScript
in the first place was to avoid postbacks on checkbox clicks that
would call server-side code to enable/disable textboxes. Any ideas are
much appreciated.

- Harry

Nov 17 '05 #2
When a form is posted, it sends the values of its fields to the server. It
does not send the attributes!

If you want to communicate client-side changes in control state to the
server, you will need to put those changes into something which will reach
the server. I've used both hidden fields and cookies for that purpose.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"Harry" <ro******@vu.union.edu> wrote in message
news:16**************************@posting.google.c om...
Hello,
I have an ASP.Net web page populated with WebControls, such as
textboxes and checkboxes. On this page I also have a JavaScript that
disables these textboxes under certain events (such as "onLoad" and
"onClick") by calling the javascript method <object>.disabled =
<true/false>. This works visably fine on the webpage, however, when I
do a postback to the server and check the <WebControl>.Enabled
property on an item I disabled via the javascript it does not reflect
its current state. Rather, it reports the Enabled property as whatever
I initilized it to. Now I believe this is because the client is never
communicating the enabled/disabled state change to the server. Is
there a work around for this that doesn't require additional server
side postbacks and validation? The whole purpose of using JavaScript
in the first place was to avoid postbacks on checkbox clicks that
would call server-side code to enable/disable textboxes. Any ideas are
much appreciated.

- Harry

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by PB | last post: by
8 posts views Thread by Bishoy George | last post: by
9 posts views Thread by Paul Keegstra | last post: by
9 posts views Thread by Ed Jay | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.