Skip to content Skip to sidebar Skip to footer

How Can I Include Additional Markup Within A 'content' Inner Property Of An Asp.net Webcontrol?

I've searched the site and I cannot find a solution for my problem, so apologies if it's already been answered (I'm sure someone must have asked this before). I have written a jQue

Solution 1:

public ITemplate Content

which then you render to the UI like:

Labellabel=newLabel();
this.Content.InstantiateIn(label);

//Render label

EDIT: Make sure the template also defines

[TemplateInstance(TemplateInstance.Single)]

as this allows you to access the controls within the template directly.

Solution 2:

You should try to use this:

win_StatusFilter.FindControl("btn_Test") // this will be a Control
win_StatusFilter.FindControl("btn_Test") as Button // this will be a Button if control found, otherwise it will be null.

Otherwise you should define some properties for your control, like in this article: http://msdn.microsoft.com/ru-ru/library/36574bf6%28v=VS.90%29.aspx


Update: According the remarks in this article about ContentTemplate property of the UpdatePanel:

http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.contenttemplate(v=VS.90).aspx

you can get controls from ContentTemplate because of TemplateInstanceAttribute value (UpdatePanel.ContentTemplate has the TemplateInstance.Single).

So you should only use this code:

[PersistenceMode(PersistenceMode.InnerProperty)] 
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] 
[TemplateInstance(TemplateInstance.Single)]
public ITemplate Content

More information at:

http://msdn.microsoft.com/ru-ru/library/system.web.ui.templateinstanceattribute(v=VS.90).aspx

Post a Comment for "How Can I Include Additional Markup Within A 'content' Inner Property Of An Asp.net Webcontrol?"