Hiding all controls contained within a placeholder

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

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


    John Guest

  2. Similar Questions and Discussions

    1. ViewState of Contained Controls?
      I've built my tab control, and it works great. Except for one problem. Any controls which are contained in any of the tabs lose state. The tab...
    2. Accessing Controls contained in another Control from ASPX Page
      Hi All! Is there any ways to get access to the controls contained in another user controls from an ASP.NET page? For example I have... -...
    3. Build control in a placeholder or like a placeholder
      Hi. I create a new custom control and it works fine. But now, I need to put it in any place on the page, like the placehold control do. Someone...
    4. Baseline Shift Controls Need to Stop Hiding
      Nehmo Richiebee Nehmo Just don't let it happen again.I might not be so charitable next time.
    5. Contained Controls not hiding as expected
      Hi I have a hidden Panel (DIV, style.visibility='hidden') control containing a hidden TextBox. If I make the Panel visible, then make the...
  3. #2

    Default Re: Hiding all controls contained within a placeholder

    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:OQHv0PJQDHA.2676@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:Obts67HQDHA.1720@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.
    > >
    > >
    >
    >

    John Guest

  4. #3

    Default Re: Hiding all controls contained within a placeholder

    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:uTlumaJQDHA.2052@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:OQHv0PJQDHA.2676@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:Obts67HQDHA.1720@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.
    > > >
    > > >
    > >
    > >
    >
    >

    William F. Robertson, Jr. Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139