PC Review


Reply
Thread Tools Rate Thread

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

 
 
sonic
Guest
Posts: n/a
 
      18th Aug 2006
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?

 
Reply With Quote
 
 
 
 
darrel
Guest
Posts: n/a
 
      18th Aug 2006
> 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


 
Reply With Quote
 
sonic
Guest
Posts: n/a
 
      22nd Aug 2006
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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
using html control to download file from client to server =?Utf-8?B?UGF1bA==?= Microsoft ASP .NET 10 3rd Oct 2006 05:12 PM
Disable copy/paste clipboard between Client and Server only? ThomasT. Microsoft Windows 2000 Terminal Server Applications 1 4th Mar 2006 12:52 PM
Disable copy/paste clipboard between Client and Server only? ThomasT. Microsoft Windows 2000 Terminal Server Clients 1 4th Mar 2006 12:52 PM
How to disable terminal server screen saver lock out in client =?Utf-8?B?R29wYWw=?= Microsoft Windows 2000 Terminal Server Clients 1 31st Aug 2005 07:36 AM
Client-Server passing values problem. Caution: some HTML Roger Helliwell Microsoft C# .NET 2 23rd Mar 2004 06:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:02 AM.