Hiding all controls contained within a placeholder

Discussion in 'ASP .Net' started by John, Jul 2, 2003.

  1. John

    John Guest

    Hi all,

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

    Regards
    John.
    John, Jul 2, 2003
    #1
    1. Advertising

  2. John

    John Guest

    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:...
    > 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" <> wrote in message
    > news:...
    > > Hi all,
    > >
    > > How do I iterate through a specific placeholder and remove or hide all
    > > controls contained within that placeholder?
    > >
    > > Regards
    > > John.
    > >
    > >

    >
    >
    John, Jul 2, 2003
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > 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:...
    > > 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" <> wrote in message
    > > news:...
    > > > Hi all,
    > > >
    > > > How do I iterate through a specific placeholder and remove or hide all
    > > > controls contained within that placeholder?
    > > >
    > > > Regards
    > > > John.
    > > >
    > > >

    > >
    > >

    >
    >
    William F. Robertson, Jr., Jul 2, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul
    Replies:
    0
    Views:
    302
  2. msnews.microsoft.com
    Replies:
    1
    Views:
    455
    =?Utf-8?B?Q2hyaXMgTW9oYW4=?=
    Sep 26, 2004
  3. nail

    Build control in a placeholder or like a placeholder

    nail, Sep 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    321
  4. Denny Smolinski via .NET 247

    Dynamic Controls, Placeholder, Retrieve Information from Dynamic Controls

    Denny Smolinski via .NET 247, May 4, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    453
    Eidolon
    May 4, 2004
  5. Warped
    Replies:
    2
    Views:
    502
    Warped
    Jul 15, 2005
Loading...

Share This Page