473,408 Members | 2,477 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,408 software developers and data experts.

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

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

Similar topics

16
by: Philippe C. Martin | last post by:
Hi, I am trying to change the data in a form field from python. The following code does not crash but has no effect as if "form" is just a copy of the original html form. Must I recreate the...
0
by: yoshra | last post by:
i want to edit form and submit (post) it to another server. the name value contain char that cannot be inisde varible name in .net "xxx" so i gave those inputtypehidden diffrent name and...
6
by: =?Utf-8?B?Unlhbg==?= | last post by:
Hi, I found out that Text property is perserved, but disable/enable status is not preserved, especially I change this setting of a server side text box with client side javascipt and then post...
4
by: =?Utf-8?B?TUNN?= | last post by:
I am trying to disable ViewState at the application level. I have the following line in my web.config: <pages enableViewState="false"></pages> But it is not working. What can I do?
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.