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

how to disable html field on client, and see that change on server

P: n/a
I realize that if a field is disabled, its value will not be posted to
server.
i realize that .Enabled = false, produces disabled="disabled" markup

i still don't see a good way to disable a field using javascript and
than check for that on the server.

if i render a regular textbox
<asp:Textbox id="txt" runat="server" />
than on client do:
txt.disabled = true; // this disables the control correctly.
than on server
txt.Enabled is true
txt.Attributes.Count is 0

if I do this on the server
txt.Attributes.Add("disabled","false");
it renders to client and is available on postback, but if i change the
value on the client to false, it does not see the new value ( because
http postback does not read values of disabled fields ) but how do i
figure out on server if an element was enabled/disabled by javascript?

Aug 18 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
but how do i
figure out on server if an element was enabled/disabled by javascript?
client side scripting can't talk to server side scripting directly. There is
no connection between the two.

What you can do is pass client side information back to the server via form
data.

So, one option is to use a hidden field, populate the value of that field
via javascript when you diable the other element, and then read that value
client-side on postback.

A bit of a hack, but pretty much the only way to get client side javascript
to communicate with the server side logic.

-Darrel
Aug 18 '06 #2

P: n/a
well that wasnt my question but since you replied, hidden field is not
the only way for JS to communicate with ther server...
you can use xmlhttprequest object to talk to server directly, or use
iframe to discretly postback and get server values back to your page
objects, or you can use the query string on regular postback

darrel wrote:
but how do i
figure out on server if an element was enabled/disabled by javascript?

client side scripting can't talk to server side scripting directly. There is
no connection between the two.

What you can do is pass client side information back to the server via form
data.

So, one option is to use a hidden field, populate the value of that field
via javascript when you diable the other element, and then read that value
client-side on postback.

A bit of a hack, but pretty much the only way to get client side javascript
to communicate with the server side logic.

-Darrel
Aug 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.