473,385 Members | 2,274 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.

Hiding all controls contained within a placeholder

Hi all,

How do I iterate through a specific placeholder and remove or hide all
controls contained within that placeholder?

Regards
John.
Nov 17 '05 #1
2 4005
Thanks Karl,

I'll give the loop through a try. The reason I don't want to set the
visibility to false is because I could have one of quite a few user controls
loaded into the placeholder and if I have say, 5 user controls loaded, the
load event will fire in each user control contained within the placeholder
which is unnecessary.

Incidentally, how does a user control differentiate between the first time
it has been loaded into a page and subsequent times?

Regards
John.
"Karl Seguin" <kseguin##crea.ca> wrote in message
news:OQ**************@TK2MSFTNGP10.phx.gbl...
Why don't you just set the visibility of the placeholder to false?

YourPlaceHolder.Visible = false

If you need to loop through this child controls, try this:

Public Sub HideControls(ByVal ParentCntrl As System.Web.UI.Control)
Dim ChildCntrl As System.Web.UI.Control
For each ChildCntrl in ParentCntr.Controls
ChildCntrl.visible = false
If ChildCntrl.HasControls = True Then
HideControls(ChildCntrl)
End If
Next
End Sub

if you actually want to loop through the controls,
"John" <a@b.com> wrote in message
news:Ob**************@TK2MSFTNGP11.phx.gbl...
Hi all,

How do I iterate through a specific placeholder and remove or hide all
controls contained within that placeholder?

Regards
John.


Nov 17 '05 #2
Set a viewstate for the control that tells whether is has been posted back
on.

in your user control:

void Page_Load(...)
{
if ( ViewState["IsUCPostback"] == null )
{
ViewState["IsUCPostback"] = true;
//data binding code
}
}

HTH,

bill
"John" <a@b.com> wrote in message
news:uT**************@TK2MSFTNGP11.phx.gbl...
Thanks Karl,

I'll give the loop through a try. The reason I don't want to set the
visibility to false is because I could have one of quite a few user controls loaded into the placeholder and if I have say, 5 user controls loaded, the
load event will fire in each user control contained within the placeholder
which is unnecessary.

Incidentally, how does a user control differentiate between the first time
it has been loaded into a page and subsequent times?

Regards
John.
"Karl Seguin" <kseguin##crea.ca> wrote in message
news:OQ**************@TK2MSFTNGP10.phx.gbl...
Why don't you just set the visibility of the placeholder to false?

YourPlaceHolder.Visible = false

If you need to loop through this child controls, try this:

Public Sub HideControls(ByVal ParentCntrl As System.Web.UI.Control)
Dim ChildCntrl As System.Web.UI.Control
For each ChildCntrl in ParentCntr.Controls
ChildCntrl.visible = false
If ChildCntrl.HasControls = True Then
HideControls(ChildCntrl)
End If
Next
End Sub

if you actually want to loop through the controls,
"John" <a@b.com> wrote in message
news:Ob**************@TK2MSFTNGP11.phx.gbl...
Hi all,

How do I iterate through a specific placeholder and remove or hide all
controls contained within that placeholder?

Regards
John.



Nov 17 '05 #3

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

Similar topics

2
by: Jamie Fraser | last post by:
Hi, Is there a way to loop through EVERY control on a form (whether they are directly on the form, or contained within children of the form)? I would like to access the size and location of...
9
by: wASP | last post by:
Hello again to all of you geniuses, I'm having a problem trying to load dynamic controls at the initialization phase. I've read the docs, and I thought I had it figured out:...
7
by: Tim T | last post by:
Hi, I have the need to use dynamically loaded user controls in a webform page. I have the controls loading dynamically, and that part works fine. this is the code used in a webform to dynamically...
2
by: Mike Speak | last post by:
I have a user control that I want to use to render 4 menu items (retrieved from db) on the top of each of my asp.net pages. The user control defines a table, with one TR and one TD. Within the...
4
by: Marius Trælnes | last post by:
Hello! I am about to make a class/control that creates tabbing functionality. The result is in HTML/CSS/JavaScript output. My question is: Within the tabs I want to simply add user controls...
6
by: Louise | last post by:
I use Visual Basic .NET Framework 1.1, Visual Studio. I have a Web page (aspx) referencing a control (ascx) that has a placeholder that is assigned one of 2 child controls through buttons. The...
8
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
3
by: JimCinLA | last post by:
I use a place holder to load different user controls on an .aspx page. Let's call this default.aspx. Each user controls contains about a dozen different ASP.Net controls. My question is, how...
1
by: John | last post by:
I am trying to get a control to insert into the HTML content for a page which comes from our database. At the point I have a tag for the component I want to add which is contained inside the HTML....
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: 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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.