ITemplate and inbedded controls

Discussion in 'ASP .Net Building Controls' started by Perecli Manole, Dec 18, 2006.

  1. I created a tabstrip custom control that is declared like this:

    <acc:TabStrip ID="Tabs" runat="server" SelectedTabID="aa"
    AutoPostBack="true">
    <Tab ID="aa" Text="aa">
    <Template/>
    </Tab>
    <Tab ID="bb" Text="bb"/>
    <Template>
    <asp:panel ID="test" ..... or any other control />
    </Template>
    </Tab>
    </acc:TabStrip>

    I am using <ControlBuilder(GetType(TabStrip.ControlBuilder)),
    ParseChildren(False)> attributes on the TabStrip Class and overrided
    AddParsedSubObject() to add the Tabs to a collection of type
    StateManagedCollection. Then somewhere in PreRender as I am iterating
    through the collection I am doing this
    "objTab.Template.InstantiateIn(objTableCell)" to place the contents of the
    template in a TableCell that is being rendered by the TabStrip control.
    Everything renderes and operates properly, however, as a control consumer, I
    have not found a way to access any of the controls contained in the
    template. In the example above I can not access the control with ID="test"
    in the code behind so if I wanted to change any properties of these
    controls, on post back, I could not. How should I change my implementation
    to allow my consumers to access the controls contained in the <Template>
    tags.

    Perry
     
    Perecli Manole, Dec 18, 2006
    #1
    1. Advertising

  2. Hi Perceli,

    I suspect you're trying to access controls that have not been created - this
    is because you instantiate template on prerender, whilst it should be done
    earlier (CreateChildControls + EnsureChildControls are designed for this), of
    course to find the control in the template, you must call FindControl of the
    control template is instantiated in, (CType(objTableCell.FindControl("test"),
    Panel) in this case)

    hope this helps

    --
    Milosz Skalecki
    MCAD


    "Perecli Manole" wrote:

    > I created a tabstrip custom control that is declared like this:
    >
    > <acc:TabStrip ID="Tabs" runat="server" SelectedTabID="aa"
    > AutoPostBack="true">
    > <Tab ID="aa" Text="aa">
    > <Template/>
    > </Tab>
    > <Tab ID="bb" Text="bb"/>
    > <Template>
    > <asp:panel ID="test" ..... or any other control />
    > </Template>
    > </Tab>
    > </acc:TabStrip>
    >
    > I am using <ControlBuilder(GetType(TabStrip.ControlBuilder)),
    > ParseChildren(False)> attributes on the TabStrip Class and overrided
    > AddParsedSubObject() to add the Tabs to a collection of type
    > StateManagedCollection. Then somewhere in PreRender as I am iterating
    > through the collection I am doing this
    > "objTab.Template.InstantiateIn(objTableCell)" to place the contents of the
    > template in a TableCell that is being rendered by the TabStrip control.
    > Everything renderes and operates properly, however, as a control consumer, I
    > have not found a way to access any of the controls contained in the
    > template. In the example above I can not access the control with ID="test"
    > in the code behind so if I wanted to change any properties of these
    > controls, on post back, I could not. How should I change my implementation
    > to allow my consumers to access the controls contained in the <Template>
    > tags.
    >
    > Perry
    >
    >
    >
     
    Milosz Skalecki, Dec 22, 2006
    #2
    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. Christophe Peillet

    Adding controls to EditableDesignerRegion/ITemplate in code.

    Christophe Peillet, Apr 4, 2006, in forum: ASP .Net Building Controls
    Replies:
    7
    Views:
    203
    Alessandro Zifiglio
    Apr 10, 2006
  2. ITemplate and ControlBuilder

    , Mar 26, 2007, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    151
  3. Luhar Powell via .NET 247

    Itemplate sample : Access controls on postback

    Luhar Powell via .NET 247, Apr 1, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    388
    Brock Allen
    Apr 1, 2005
  4. Brook

    Custom Control, ITemplate and nested bound controls

    Brook, Mar 17, 2008, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    465
    Brook
    Mar 25, 2008
  5. George

    Persist viewstate in ITemplate child controls

    George, Nov 13, 2009, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    1,019
    George
    Nov 13, 2009
Loading...

Share This Page