473,513 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Visibility of servercontrols thrue javascript

Hi,
Anyone know if it's possible to set the visibilty of a servercontrol thru
javascript.
Think it would go something like this, but its not working:

document.forms[0]['TextBox1'].style.visibility == 'hidden'

Thanks
T.
---------
Diving the blue deep.
Sep 13 '06 #1
6 1330
There is no way to do this.

You can control whether the control is visible in the browser. But this has
nothing to do with the Visible property on the server. In fact, if Visible
is False on the server, the HTML for that control won't even be streamed
down to the client.

"Dahab" <tr********@hotmail.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
Hi,
Anyone know if it's possible to set the visibilty of a servercontrol thru
javascript.
Think it would go something like this, but its not working:

document.forms[0]['TextBox1'].style.visibility == 'hidden'

Thanks
T.
---------
Diving the blue deep.

Sep 13 '06 #2
Not working even without me typo !
Sorry !

"Dahab" <tr********@hotmail.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
Hi,
Anyone know if it's possible to set the visibilty of a servercontrol thru
javascript.
Think it would go something like this, but its not working:

document.forms[0]['TextBox1'].style.visibility == 'hidden'

Thanks
T.
---------
Diving the blue deep.

Sep 13 '06 #3
Hi Marina,
I'm only trying to hide the servercontrol on the client.
Thanks

T.

"Marina Levit [MVP]" <so*****@nospam.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
There is no way to do this.

You can control whether the control is visible in the browser. But this
has nothing to do with the Visible property on the server. In fact, if
Visible is False on the server, the HTML for that control won't even be
streamed down to the client.

"Dahab" <tr********@hotmail.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
>Hi,
Anyone know if it's possible to set the visibilty of a servercontrol thru
javascript.
Think it would go something like this, but its not working:

document.forms[0]['TextBox1'].style.visibility == 'hidden'

Thanks
T.
---------
Diving the blue deep.


Sep 13 '06 #4
Jippi its working!
Thanks..

"Marina Levit [MVP]" <so*****@nospam.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
There is no way to do this.

You can control whether the control is visible in the browser. But this
has nothing to do with the Visible property on the server. In fact, if
Visible is False on the server, the HTML for that control won't even be
streamed down to the client.

"Dahab" <tr********@hotmail.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
>Hi,
Anyone know if it's possible to set the visibilty of a servercontrol thru
javascript.
Think it would go something like this, but its not working:

document.forms[0]['TextBox1'].style.visibility == 'hidden'

Thanks
T.
---------
Diving the blue deep.


Sep 13 '06 #5
Hi,

Dahab wrote:
Not working even without me typo !
Sorry !

"Dahab" <tr********@hotmail.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
>>Hi,
Anyone know if it's possible to set the visibilty of a servercontrol thru
javascript.
Think it would go something like this, but its not working:

document.forms[0]['TextBox1'].style.visibility == 'hidden'

Thanks
T.
JavaScript can only control a CSS style attribute if it is set in the
first place. In your case, you must get the server-side control to add a
"style" attribute with the value "visibility: visible;". This is usually
done using the control's Attributes collection.

Note that for this kind of effects, you probably rather want to use
display: "display: block;".

After that, JavaScript can access the element, and modify the style
attribute:

if ( document.getElementById( "TextBox1" )
&& document.getElementById( "TextBox1" ).style
&& document.getElementById( "TextBox1" ).style.display )
{
document.getElementById( "TextBox1" ).style.display = "none";
}

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 13 '06 #6
Hi Laurent,
This is very good information
Thanks
T.
"Laurent Bugnion" <ga*********@bluewin.chwrote in message
news:uK***************@TK2MSFTNGP06.phx.gbl...
Hi,

Dahab wrote:
>Not working even without me typo !
Sorry !

"Dahab" <tr********@hotmail.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
>>>Hi,
Anyone know if it's possible to set the visibilty of a servercontrol thru
javascript.
Think it would go something like this, but its not working:

document.forms[0]['TextBox1'].style.visibility == 'hidden'

Thanks
T.

JavaScript can only control a CSS style attribute if it is set in the
first place. In your case, you must get the server-side control to add a
"style" attribute with the value "visibility: visible;". This is usually
done using the control's Attributes collection.

Note that for this kind of effects, you probably rather want to use
display: "display: block;".

After that, JavaScript can access the element, and modify the style
attribute:

if ( document.getElementById( "TextBox1" )
&& document.getElementById( "TextBox1" ).style
&& document.getElementById( "TextBox1" ).style.display )
{
document.getElementById( "TextBox1" ).style.display = "none";
}

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch

Sep 13 '06 #7

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

Similar topics

2
5972
by: Justin Wright | last post by:
Greetings - I am trying to set up a page where there are a couple of checkboxes, and based on the selected checkbox, certain input fields are required. For the required fields, I want to...
4
2803
by: Jonathan | last post by:
Hi, I've read through quite a number of postings on here so far and have seen what look like very simply, reasonable answers to this question, however I am still completely unable to do what I...
12
3868
by: lawrence | last post by:
The following function correctly makes everything invisible but then fails to turn the one chosen DIV back to visible. I imagine I'm getting the syntax of the variable wrong? I've tried this with...
4
5443
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) {...
4
1581
by: jmensch | last post by:
I'm reasonably new to JavaScript and DHTML, so I'm sorry if this is an obvious mistake. The following snippet of code is intended to make the menu -- the absolute-positioned <div> section --...
1
1645
by: Jim Heavey | last post by:
Hello, I create a HTML line as follows: <P class=text12BoldRed id=ErrTimePeriodSelection style="VISIBILITY: hidden" runat="server">Selection of time period either not made or more then one type...
3
1166
by: Animal | last post by:
Hey, I've got the following problem: I'm trying to create a small tool that must be able to search thrue a database using a search-criteria, that has to be entered by the user in a TextBox. The...
3
3308
by: dwilson | last post by:
Hi Folks, I am having a strange Javascript issue. I have a div that I show and hide by clicking on an image link, and all images within the div do not show up in IE. FireFox does not give me...
11
2602
by: -D- | last post by:
How can I turn the visibility of the xml control on or off? <%@ Control Language="c#" AutoEventWireup="false" Codebehind="TopNavBar.ascx.cs" Inherits="compass.user_controls.TopNavBar"...
0
7267
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
7175
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
7391
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7553
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...
1
7120
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7542
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...
1
5100
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...
0
4754
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1609
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.