473,609 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use javascript to hide or show an ASP.Net control?

Is this possible at all? I'm working on a Atlas project which at one point
requires me to hide an ASP.net control with Javascripts running on the
client side.

Anyone able to provide any help on this?

Thanks.
Apr 24 '06 #1
6 2169
GSL
Unless I misunderstood the question, the following js should work:

document.getEle mentById( {ID of ASP.net control} ).style.display = 'none'.

"Nestor" <n3****@yahoo.c om> wrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Is this possible at all? I'm working on a Atlas project which at one point
requires me to hide an ASP.net control with Javascripts running on the
client side.

Anyone able to provide any help on this?

Thanks.

Apr 24 '06 #2
Thanks, that worked pretty well.... if my control is initially not visible,
how do i get it to show on later? Seems like the javascript can't get the
object if the initial state is not visible?
"GSL" <Gu***********@ gmail.com> wrote in message
news:Eo******** *************** *******@comcast .com...
Unless I misunderstood the question, the following js should work:

document.getEle mentById( {ID of ASP.net control} ).style.display = 'none'.

"Nestor" <n3****@yahoo.c om> wrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Is this possible at all? I'm working on a Atlas project which at one
point
requires me to hide an ASP.net control with Javascripts running on the
client side.

Anyone able to provide any help on this?

Thanks.


Apr 25 '06 #3
GSL
try the style's setAttribute method,

hide:
....style.setAt tribute('displa y', 'none')

show:
....style.setAt tribute('displa y', '')

note: ''could be replaced with 'block', 'inline', etc.

fyi, "display: none" hides the element and collapses the area that it
occupied, "visibility : none" just hides the element.

"Nestor" <n3****@yahoo.c om> wrote in message
news:O9******** ******@TK2MSFTN GP02.phx.gbl...
Thanks, that worked pretty well.... if my control is initially not visible, how do i get it to show on later? Seems like the javascript can't get the
object if the initial state is not visible?
"GSL" <Gu***********@ gmail.com> wrote in message
news:Eo******** *************** *******@comcast .com...
Unless I misunderstood the question, the following js should work:

document.getEle mentById( {ID of ASP.net control} ).style.display = 'none'.
"Nestor" <n3****@yahoo.c om> wrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Is this possible at all? I'm working on a Atlas project which at one
point
requires me to hide an ASP.net control with Javascripts running on the
client side.

Anyone able to provide any help on this?

Thanks.



Apr 25 '06 #4
GSL
one more thought. if the control is initially not visible because you set
the "Visible" property in the code-behind to false, then it is not possible
to show it using js. The reason is that asp.net will not generate any html
for controls where the "Visible" property is false. Instead, you should set
the control's style display attribute to 'none' in the code-behind.

"Nestor" <n3****@yahoo.c om> wrote in message
news:O9******** ******@TK2MSFTN GP02.phx.gbl...
Thanks, that worked pretty well.... if my control is initially not visible, how do i get it to show on later? Seems like the javascript can't get the
object if the initial state is not visible?
"GSL" <Gu***********@ gmail.com> wrote in message
news:Eo******** *************** *******@comcast .com...
Unless I misunderstood the question, the following js should work:

document.getEle mentById( {ID of ASP.net control} ).style.display = 'none'.
"Nestor" <n3****@yahoo.c om> wrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Is this possible at all? I'm working on a Atlas project which at one
point
requires me to hide an ASP.net control with Javascripts running on the
client side.

Anyone able to provide any help on this?

Thanks.



Apr 25 '06 #5
Hi,

I'll add one more question: It seems some features of STYLE are not
supported everywhere, everytime. What can we do with that?

Afshar

Apr 25 '06 #6
You should set the style.display property of the HTML element that the
Control renders on the client, on the client. The code that you've been
given is server-side code.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Nestor" <n3****@yahoo.c om> wrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Is this possible at all? I'm working on a Atlas project which at one point
requires me to hide an ASP.net control with Javascripts running on the
client side.

Anyone able to provide any help on this?

Thanks.

Apr 25 '06 #7

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

Similar topics

5
4494
by: Steve | last post by:
Visual Studio 2003 C# Windows: I have a tree view control as my main menu control down the left side of my application. This has 2 Parent Nodes on it (Jobs and Employees). beneath these 2 main functions I have 2 sub functions under each("Add Job", "View Jobs" and "Add User", "View Users"). I have theses subfunctions grouped in a TabControl, so there are 2 TabControl objects on my main screen, each with 2 pages on. When the user...
1
14523
by: Oliver Hoehle | last post by:
Hello! This ist the source-code for an editable combobox implemented with HTML,CSS and Javascript. I have tested it with IE and Mozilla. But I don't know, if it will work in other browsers (Opera, Konqueror, etc.) So I need your feedback... Regards
4
17032
by: James | last post by:
Hello group: I'm trying to hide a panel control in javascript when a print button is clicked. On my web form, I have a button that fires a javascript function called doPrint(). No matter how I attempt to write the line to reference the panel control, I get a Null error or an Object does not exist error. I know this can be done in asp.net, but I need the event to fire at the client, otherwise the page will print before firing the...
2
1773
by: Red | last post by:
Can you access web form control via javascript ie.. if I have <asp:textbox runat=server id=txtTextbox/> can I say in javascript txtTextbox.Enabled = true; ??
5
10783
by: Ben | last post by:
I have a javascript code in the ASP.NET page. I want to access Calendar control that is inside ASP page and is "run at server". I try to use following code but it doesn't work. <script language="javascript"> function valSubmit() { document.getElementById("Calendar1").style.visibility =
1
1335
by: Brenton | last post by:
Hi I'm new to the group so if I make a major blunder posting this here I apologise in advance. I'm not a Programmer by any stretch of the imagination and I've been trying to sort out a small JavaScript that I found here: http://www.interspire.com/content/articles/10/1/Building-An-Expanding-DHTML-Menu-With-CSS-and-JavaScript if I use what is supplied it works fine, but a little further down
1
4939
by: Bob | last post by:
Hi, Hope you can help me with this one. I'm at my wits end. I'm trying to create an intelligent edit-box like the excellent "Customer" one at the URL: http://munich.schwarz-interactive.de/autocomplete.aspx
5
1909
by: Peter Afonin | last post by:
Hello, I'm not an expert in Javascript, so I'm seeking an advice. As I mentioned in my previous post, I use Javascript to check whether at least one checkbox in the datagrid has been checked. I have to use Stringbuilder to do this: Dim iCount As Int32 Dim sClientSideValidate As New StringBuilder
7
3581
by: hollopeterb | last post by:
my javascript code works great in IE but not in Firefox, can anyone help? Thanks!! Here is the code: <script type="text/javascript"> <!-- function MM_findObj(n, d) { //v3.0 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames.document; n=n.substring(0,p);} if(!(x=d)&&d.all) x=d.all; for (i=0;!x&&i<d.forms.length;i++) x=d.forms; for(i=0;!x&&d.layers&&i<d.layers.length;i++)...
0
8129
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8074
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8571
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8220
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8404
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6056
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4017
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4080
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1386
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.