a custom control that does not render

Last post 11-11-2009 5:23 AM by Allen Chen – MSFT. 3 replies.

Sort Posts:

  • a custom control that does not render

    11-04-2009, 8:23 PM
    • Member
      point Member
    • kevcpu_1
    • Member since 10-23-2009, 10:23 PM
    • Posts 8

    is it possible to create a control that contains child controls without rendering it.  So, when I add it to the page it should look like....

     

    <test:parentcontrol id="parent1" runat="server" property1="value1" ... propertyn="valuen">

         <test:childcontrol id="child1" runat="server" property1="value1" ... propertyn="valuen"/>

         <test:childcontrol id="child3" runat="server" property1="value1" ... propertyn="valuen"/>

         <test:childcontrol id="child3" runat="server" property1="value1" ... propertyn="valuen"/>

    </test:parentcontrol>

     

    and have the render empty, because it does not equate to anything on the html side.  Further, can I cycle through the child control of the parent using the following methodology within the code_behind file:

    foreach (Control control in parent1.Controls){

       .......

    }

     

    would this be possible if I am not technically rendering anything?  Also, would I have to do anything special with creating the parent and child controls?

     

  • Re: a custom control that does not render

    11-04-2009, 9:04 PM
    • Participant
      1,736 point Participant
    • atifsarfraz
    • Member since 10-06-2009, 3:55 PM
    • Florida
    • Posts 274

    You cannot create a control have it available in the page without rendering it. However you can hide the control in such a way that it is not viewable. To do so put a DIV on your page and set display:none or visibility:hidden

    <Div style="display:none;">

    <test:parentControl .............................>

    </test:parentControl>

    </Div

    Regards,

    Atif Sarfraz

    Please mark this post as answered if it helped you!
  • Re: a custom control that does not render

    11-04-2009, 9:17 PM
    • Member
      point Member
    • kevcpu_1
    • Member since 10-23-2009, 10:23 PM
    • Posts 8

    It is not available if it does not render?  When happens if a control has render=true?  Is it still available to the Page object?  The problem is that I dont want anything to render in this scenario, this will be information I want hidden completely from users.  I just want to drop the controls on the page, set a few properties and access the children from the code_behind.  I dont have anything to render.

  • Re: a custom control that does not render

    11-11-2009, 5:23 AM
    Answer

    Hi,

    One simple option is to set Visible property of your control to false. If you want to persist data a sophisticated way is to derive from Control and store data at server side by using Session, Cache, Application, etc.

    Sincerely,
    Allen Chen
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (4 items)