ITemplate and inbedded controls

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

  1. #1

    Default ITemplate and inbedded controls

    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 Guest

  2. Similar Questions and Discussions

    1. ITemplate
      Can I assign a text box to the template? Like this: Dim template1 As ITemplate template1 = Button2
    2. Adding controls to EditableDesignerRegion/ITemplate in code.
      I have a base custom control called 'WebBox' that contains a single EditableDesignerRegion. The contents of this EditableDesignerRegion are stored...
    3. RaiseBubbleEvent from ITemplate
      HI, I am writing a Web User control to display the Data in groups. For each column of my source dataTable, I created a new DataTable (say...
    4. ASP.NET ControlBuilder with ITemplate
      Hi, Does anyone has already implemented an ASP.NET custom control with a custom ControlBuilder and having this control supports one or many...
    5. Array of ITemplate
      Hi There I don't know if this is at all possible. I want to create an array of ITemplate as a property for my web server control. Like in the...
  3. #2

    Default RE: ITemplate and inbedded controls

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