473,385 Members | 1,893 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.

Hide all controls in a panel in ASP.Net

35
Hi

Simply i want Hide all Textboxes in a Panel ,,, in asp.net

i can do it by C# :
Expand|Select|Wrap|Line Numbers
  1. foreach (Control ctrl in Panel1.Controls)
  2. {
  3. if (ctrl is TextBox)
  4. {
  5. ((TextBox)(ctrl)).Visible = false;
  6. }
  7.  
  8. }
  9.  
Can anyone tell me how to do in JavaScript?
Oct 15 '07 #1
6 4047
jhardman
3,406 Expert 2GB
moved to .NET forum
Oct 17 '07 #2
Frinavale
9,735 Expert Mod 8TB
Hi
...

Can anyone tell me how to do in JavaScript?
What have you tried so far?

-Frinny
Oct 17 '07 #3
Hi

Simply i want Hide all Textboxes in a Panel ,,, in asp.net

i can do it by C# :
Expand|Select|Wrap|Line Numbers
  1. foreach (Control ctrl in Panel1.Controls)
  2. {
  3. if (ctrl is TextBox)
  4. {
  5. ((TextBox)(ctrl)).Visible = false;
  6. }
  7.  
  8. }
  9.  
Can anyone tell me how to do in JavaScript?
Simple, just set the display = none of the whole panel, and it makes it easier since you hide the whole panel, and you dont have to worry about controls in it.

try:

javascript:

Expand|Select|Wrap|Line Numbers
  1. function hide()
  2. {
  3.     document.getElementById("Panel1").style.display="none";
  4. }
if you want to hide a specific element you just do the same:

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("TextBox1").style.display="none";
Oct 17 '07 #4
Frinavale
9,735 Expert Mod 8TB
Simple, just set the display = none of the whole panel, and it makes it easier since you hide the whole panel, and you dont have to worry about controls in it.

try:

javascript:

Expand|Select|Wrap|Line Numbers
  1. function hide()
  2. {
  3.     document.getElementById("Panel1").style.display="none";
  4. }
if you want to hide a specific element you just do the same:

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("TextBox1").style.display="none";
Close.....
Expand|Select|Wrap|Line Numbers
  1. function hide()
  2. {
  3.     document.getElementById("Panel1").style.display="none";
  4. }
Won't work if your panel is part of a user control or within a MasterPage.

You'll have to supply Panel1.ClientID to the function.
(or TextBox1.ClientID)
This way the JavaScript will be able to find your element.

Please see the .NET article on How to check if a textbox contains a number for more information on how generate JavaScript dynamically through your .NET code and send it to the browser.

-Frinny
Oct 17 '07 #5
DAnDA
35
Thank you All Guys ,,,
Oct 21 '07 #6
kunal pawar
297 100+
If you want to hide all controls in Panel then you can directly hide Panel

used
document.getElementById('Panel Id').style.display='hidden'
Oct 24 '07 #7

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

Similar topics

1
by: alexB | last post by:
Panel sucks! I don't use it because it's so quirky. >-----Original Message----- >The panel control seems to be the right tool to group controls on a page, >but I seem to loose all ability to...
0
by: Efkas | last post by:
I have a full custom application with some widged extending Controls like Label and PictureBox. I build a menu with these widgets. When I click on one of them, it calls a function to display...
12
by: Jerad Rose | last post by:
I searched for a while trying to find the answer to this, but to no avail. I am trying to find the best way (or any way) to dynamically show and hide groups of TR's. For example, I have a...
1
by: Jeremy S | last post by:
I want to show or hide a bunch of related controls at runtime (textboxes, labels, check boxes). Is the Panel control the only way to go? Are there alternatives? Thanks.
5
by: dje | last post by:
In the OnClick event on a radioButtonList, I run a javascript to show/hide the appropriate div along with a submit button, which displays as expected. The problem is the submit no longer works on...
2
by: Øyvind Isaksen | last post by:
Is it possible to show/hide a usercontrol code behind? <uc1:topart id="Topart1" runat="server"></uc1:topart> This is what i want to do, but this does not work: if objDR.read me.Topart1.show...
1
by: Aravind | last post by:
Can anyone suggest me how to design auto hide feature for a panel control. I have a few controls in a panel. I want to auto hide them when user is not working with them. Thank you for you help...
2
by: Nathan Sokalski | last post by:
I have an HTML table in which I am using ASP:Panel controls to group together <tr>'s so that I can more easily show/hide them (by setting the ASP:Panel's Visible property). This works fine, but...
2
by: Badass Scotsman | last post by:
Hello, I have two files, default.aspx and default.aspx.cs. On my ASPX file I have the following code: <asp:panel ID="MyPanel" runat="server"> Content Here </asp:panel> And I want to...
1
by: vvgopal2k | last post by:
Hi Group, I am facing a problem in ASP.net usercontrols. Here is the Program. When a Click a button on the usercontrol page, a panel shows up on the same user control, this panel has some...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: 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
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
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...

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.