Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > ITemplate and inbedded controls

Reply
Thread Tools

ITemplate and inbedded controls

 
 
Perecli Manole
Guest
Posts: n/a
 
      12-18-2006
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>
<aspanel 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


 
Reply With Quote
 
 
 
 
Milosz Skalecki
Guest
Posts: n/a
 
      12-22-2006
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>
> <aspanel 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
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Persist viewstate in ITemplate child controls George ASP .Net Web Controls 0 11-13-2009 05:37 PM
Custom Control, ITemplate and nested bound controls Brook ASP .Net Web Controls 4 03-25-2008 02:55 PM
ITemplate and ControlBuilder richard.szalay@gmail.com ASP .Net Building Controls 0 03-25-2007 11:19 PM
Adding controls to EditableDesignerRegion/ITemplate in code. Christophe Peillet ASP .Net Building Controls 7 04-10-2006 02:22 PM
Itemplate sample : Access controls on postback Luhar Powell via .NET 247 ASP .Net Web Controls 1 04-01-2005 03:39 PM



Advertisments