Hiding all controls contained within a placeholder

J

John

Hi all,

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

Regards
John.
 
J

John

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.
 
W

William F. Robertson, Jr.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,078
Messages
2,570,572
Members
47,204
Latest member
MalorieSte

Latest Threads

Top