I want to create custom templated control which controls inside of template coluld be got in page (a behavior similar to updatepanel). So, issue in more details.
The control has to look like:
<ec:TabControl runat="server" ID="tab">
<Tabs>
<ec:Tab runat="server">
<TabContainer>
<asp:Button runat="server" Text="aaaaaa" />
</TabContainer>
<TabName>
text or controls
</TabName>
</ec:Tab>
<ec:Tab runat="server">
<TabContainer>
<asp:Button runat="server" Text="vcxvxvxv" />
</TabContainer>
<TabName>
some text
</TabName>
</ec:Tab>
</Tabs>
</ec:TabControl>
It works well in way as databound control operates. In other words, during ondatabound stage all controls inside and templates are instanated appropriately.
But what i do want is to have access to controls inside and directly from page (by ID). For example, you can do it using updatepanel (content of is avaiable within page scope).
Below you can see fragment of control’s source code:
public class Tab
{
[PersistenceMode(PersistenceMode.InnerProperty)]
[TemplateContainer(typeof(HtmlAnchorContainer))]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ITemplate TabName { get; set; }
[PersistenceMode(PersistenceMode.InnerProperty)]
[TemplateContainer(typeof(PanelContainer))]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ITemplate TabContainer { get; set; }
}
public class TabControl : System.Web.UI.WebControls.WebControl
{
List<Tab> tabs;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerProperty),
NotifyParentProperty(true)]
public List<Tab> Tabs
{
get { return tabs ?? new List<Tab>(); }
set { tabs = value; }
}
protected override void CreateChildControls()
{
base.CreateChildControls();
.....
foreach (Tab tabItem in Tabs)
{
//generating tree control for further rendering
}
...
}
protected override void OnDataBinding(EventArgs e)
{
EnsureChildControls();
base.OnDataBinding(e);
}
}
Hope for you advices, recommendations, links and constructive criticism.))
Apply a:
declaration to your templates where you want to reference the control directly, then this should be resolved.