473,385 Members | 1,922 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,385 software developers and data experts.

visible = true/false

karenRoss
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 5268
Frinavale
9,735 Expert Mod 8TB
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 Expert 4TB
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
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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...

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.