Hiding all controls contained within a placeholder

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi all,

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

Regards
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.
 
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
 
Back
Top