473,408 Members | 2,888 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.

server side controls disabled in javascript

I have a requirement to disable some textboxs depending on their
contents. I choose to do this by invoking some javascript. When they
change the contents, i disable the textbox they just put new data into
and focus on another textbox.

My logic works fine, the textboxes get disabled.

However, when the page posts back, the disabled textbox contents (which
were changed before disabling) DOES NOT GO BACK TO THE SERVER. The
server gets the old value instead. I have found some references to this
but I would like to hear some other peoples experences with this. Is it
solveable?
I can solve this by using the Vb.net enable property instead but it
requires a postback which i trying to advoide.

A related queston. VB.net textboxs have their own enable property. The
dom object has it's disabled property. It's the dom object disabled
propety that is causing this behavior. So the quesiton is, can i set
the vb.net textbox.enable property instead of the dom object's version
from Javascript? This would also solve my problem.

Nov 19 '05 #1
8 5419
> However, when the page posts back, the disabled textbox contents
(which
were changed before disabling) DOES NOT GO BACK TO THE SERVER. The
server gets the old value instead. I have found some references to
this
but I would like to hear some other peoples experences with this. Is
it
solveable?
This is because ASP.NET is a server side technology and every request tot
he server recreates the page and all the controls on the page. Anything you've
done in the browser in javascript is not known to the server. You can make
this work, but nothing's built in to do this, so i'll be manual. To make
it work you just need to convey the right information to the server and then
write the cde to enable/disable those controls based upon the info you've
sent to the server.
dom object has it's disabled property. It's the dom object disabled
propety that is causing this behavior. So the quesiton is, can i set
the vb.net textbox.enable property instead of the dom object's version
from Javascript? This would also solve my problem.


Yes, you can set that property on the server side control and when it renders
it will emit the right style to make it disabled in the browser. But again,
if you change that value in the browser, you'll have to somehow let the server
know the next time you do a postback so you can keep the client enabled/disabled
state in synch with the server side enabled/disable state.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Nov 19 '05 #2
Thank you very much for responding so quickly. I'm not sure you
answered the question. The problem is with the contents of a control
that was changed then disabled with javascript. On sumit Its contents
are not going back to the server because it's disabled.

And again that you so much for the quick response.

Nov 19 '05 #3
Also, how would you set the textbox.enable=false from javascript?
Remember not the dom.disabled but the vb.net textbox.enable property.

Nov 19 '05 #4
How about enabling the text boxes just before submit by also using Java
script. Add a handler to the Form's onsubmit, in the HTML view add something
like this to the form:
<form onsubmit="EnableBoxes();" id="Form1" .....
Then in the function EnableBoxes you enable the boxes that were disabled.
Your function will run before the submit and results will be as expected.

"CsaaGuy" <ro********@csaa.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
I have a requirement to disable some textboxs depending on their
contents. I choose to do this by invoking some javascript. When they
change the contents, i disable the textbox they just put new data into
and focus on another textbox.

My logic works fine, the textboxes get disabled.

However, when the page posts back, the disabled textbox contents (which
were changed before disabling) DOES NOT GO BACK TO THE SERVER. The
server gets the old value instead. I have found some references to this
but I would like to hear some other peoples experences with this. Is it
solveable?
I can solve this by using the Vb.net enable property instead but it
requires a postback which i trying to advoide.

A related queston. VB.net textboxs have their own enable property. The
dom object has it's disabled property. It's the dom object disabled
propety that is causing this behavior. So the quesiton is, can i set
the vb.net textbox.enable property instead of the dom object's version
from Javascript? This would also solve my problem.

Nov 19 '05 #5
Ah, I see what you're saying. Well, it seems you're running into a browser
or HTML issue. Controls that are disabled simply aren't posted to the server.
I don't know if that's specific to the HTML, but it seems to be the case
for both Firefox and IE.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Thank you very much for responding so quickly. I'm not sure you
answered the question. The problem is with the contents of a control
that was changed then disabled with javascript. On sumit Its contents
are not going back to the server because it's disabled.

And again that you so much for the quick response.

Nov 19 '05 #6
Cool, that worked. Its a kludge but it works! Thanks. My other life
intruded so sorry for the delay. By the way, Is there a way to set the
<asp:TextBox>'s version enabled property from Javascript? Microsoft
worked around this problem by not using the DOM disabled property. They
cheated somehow.

Thanks again.

Nov 19 '05 #7
Actually <asp:TextBox> is something that lives only on the server, the stuff
that reaches your browser is HTML, so on the server when rendering, the
output of the MS Controls are converted to their HTML buddies. Do a "View
Source" on the browser to see what the MS control looks like in the browser.
So the answer is no, you can't use Java script to access the MS text box,
because Java script can only access stuff that is in the browser.

"CsaaGuy" <ro********@csaa.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Cool, that worked. Its a kludge but it works! Thanks. My other life
intruded so sorry for the delay. By the way, Is there a way to set the
<asp:TextBox>'s version enabled property from Javascript? Microsoft
worked around this problem by not using the DOM disabled property. They
cheated somehow.

Thanks again.

Nov 19 '05 #8
Another approach is to make the textbox read-only and change it's class
to one that makes it appear as if its disabled.

Nov 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: James Baker | last post by:
Is it possible to run a Server Side function from JavaScript? I have a dropdown list that executes some javascript in the onChange event, but I need it to query a database after it does so. ...
1
by: eNathan | last post by:
I want to be able to disable\enable controls on the client via client-side scripting. I'm trying to avoid a postback. I'd like to use HTML and server-side controls on the same page. In code-behind...
4
by: Don Parker | last post by:
Does the use of server side controls eg <asp:textbox> preclude the access to that control by client script? If not, how do you reference those elements? *** Sent via Developersdex...
4
by: KK | last post by:
Hi, Does anybody know how to call server side function in javascript? Suppose I've a method named Test() at code behind of ASP.Net page. How can I call that method in javascript function ???...
0
by: Polly Anna | last post by:
Hi, I have created an xsl document containing html client side controls and when I used my XSLCompileTransform class it successfully created an xhtml page. I then changed the client side controls...
4
by: Paul | last post by:
Hi all, I have a page with a mutli view control where one of the views needs to contain a separate HTML get form with a submit button that goes to another page. In ASP this was no problem -...
1
by: shri124 | last post by:
please tell me what is the difference between the client side and server side controls?
5
by: =?Utf-8?B?Q2FybG8gRm9saW5p?= | last post by:
Hi, I'm starting studying ATLAS. First thing that I'm concerned about is if the ATLAS controls are a pluggable options for server side controls.. What I wonder is if the case ATLAS extension are...
2
by: Eric Layman | last post by:
Hi, Sorry. I'm happily writing scripts / converting scripts to asp.net Then i realise: How do i apply style sheets to the controls? Usually i can just <input type="text"...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.