473,467 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

visible = true/false

karenRoss
27 New Member
hi!

I was wondering if anyone knows of a way to show and hide an asp panel based on a user click on a page.

Or should I use javascript and CSS tags to show/unshow the table I want?

I might not know the ID to some of these objects and I think that might be a problem.

Any thoughts?
Jun 1 '07 #1
3 5270
Frinavale
9,735 Recognized Expert Moderator Expert
hi!

I was wondering if anyone knows of a way to show and hide an asp panel based on a user click on a page.

Or should I use javascript and CSS tags to show/unshow the table I want?

I might not know the ID to some of these objects and I think that might be a problem.

Any thoughts?
You can use JavaScript and CSS if you'd like to. Remember that if you set an element in your Server Side code it will simply not write that object to browser. Therefore you can't refer to the object using JavaScript or CSS if you've set something to be visible=false in your Server Side code.

You can always refer to your asp panel's client id..pass it to your JavaScript to control its CSS properties.

Eg:
Expand|Select|Wrap|Line Numbers
  1.  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.   CheckBoxVisibilitiy.Attributes.Add("OnClick", "SetPanelVisibility('" + myPanel.ClientID + "');")
  3. ...
  4. End Sub
  5.  
Expand|Select|Wrap|Line Numbers
  1. <script>
  2.     function SetPanelVisibility(nameOfPanel)
  3.     {    if(condition....)
  4.          {
  5.              document.getElementByID(nameOfPanel).visible = 'visible'
  6.          }
  7.     }
  8. </script>
  9.  
  10.  
Hope this helps!

-Frinny
Jun 1 '07 #2
Plater
7,872 Recognized Expert Expert
Expand|Select|Wrap|Line Numbers
  1. <script>
  2.     function SetPanelVisibility(nameOfPanel)
  3.     {    if(condition....)
  4.          {
  5.              document.getElementByID(nameOfPanel).visible = 'visible'
  6.          }
  7.     }
  8. </script>
  9.  
-Frinny
Be aware that document.getElementByID() is not a universal syntax (firefox/netscape is a little different I think)

It's recomended to try this instead:
Expand|Select|Wrap|Line Numbers
  1. function returnObjById( id ) 
  2.    if (document.getElementById) 
  3.       var returnVar = document.getElementById(id); 
  4.    else if (document.all) 
  5.      var returnVar = document.all[id]; 
  6.    else if (document.layers) 
  7.       var returnVar = document.layers[id]; 
  8.    return returnVar; 
  9.  
Jun 1 '07 #3
karenRoss
27 New Member
Thanks for your input guys! It was a big help. I was able to put together some sort of javascript that worked.
Jun 1 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Stanley J Mroczek | last post by:
I Set the EditCommandColumn to Visible=False to stop people who are not allowed to make any changes to a record. How can set it to Visible=true for some users? Please answer in VB Thanks Stan
0
by: Eric J Owens | last post by:
Thanks and Hello to you! I have a form in A2k that has a tab control on it. The form opens the first page and filters the records I want just fine. When I click a tab, to view another set of...
3
by: Susan Bricker | last post by:
Greetings. I have three forms that are open at the same time. They are related and cascading. The first form (frmEventAdd) is the anchor. Each event can have many Trials. The second form is...
6
by: Nick Stansbury | last post by:
Hi, I have a loop running on Page_PreRender that sets a number of controls to invisible based on a set of criteria. Before I do this however, I set all of the drop down lists to be visible with...
16
by: Miguel Dias Moura | last post by:
Hello, i have 5 panels in an ASP.net / VB page. The panel 1 is visible the other 4 are NOT visible. I also have 5 images: image 1, image 2, ..., image5. When i click one of the images,...
6
by: Marc Robitaille | last post by:
Hello, Hello, I developed a UserControl. It has funny behavior. It is composed of three controls. A texbox, a combobox and a button. There are three properties to indicate the visibility of...
2
by: aharding | last post by:
I have fields that are set to be visible or not visible based on the value of another field. These results are displayed in a continuous subform. It works fine except that it only displays the...
8
by: Doc John | last post by:
I have an MDI container with a child Form which will be visible according to certain events. The problem is that when I set the property Visible to False and then back to True, the Form will be in...
3
by: =?Utf-8?B?RnJlZHJpaw==?= | last post by:
Hi I have a problem in one of my user controls that I cannot find any solution for. I'am running C# for Visual studio 2003 and developing a windows application. The problem is the following: I...
8
by: Dan | last post by:
Hi, i experimented with postback and viewstate. With this code, there are 2 dropdownlists created, one visible and with AutoPostBack true, the other not visible and no AutoPostBack, and one...
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
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
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
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
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
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
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...
0
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.