Templated User Control & intellisense

F

Frédéric Mayot

Hi,
I built a very simple templated user control but unfortunately, the template
"Content" is not recognized by intellisense and it says that my component
"SubForm" is not supposed to contain anything.
Any idea ?
Thanks

SubForm.ascx-------------------------
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SubForm.ascx.cs"
Inherits="SubForm" %>
<asp:placeHolder runat="server" ID="pl" />


SubForm.ascx.cs----------------------
public partial class SubForm : MyBaseUserControl {

protected void Page_Init() {
if (content != null) {
Content container = new Content();
Content.InstantiateIn(container);
pl.Controls.Add(container);
}
}

private ITemplate content = null;

[TemplateContainer(typeof(Content)),
TemplateInstance(TemplateInstance.Single)]
public ITemplate Content {
get { return this.content; }
set { this.content = value; }
}
}

public class Content : Control, INamingContainer{}

Using---------------------------------
<puc:SubForm runat="server">
<Content>
<asp:Label runat="server" />
something else
etc.
</Content>
</puc:SubForm>
 
B

Brock Allen

You also need to apply
[PersistenceMode(PersistenceMode.InnerProperty)]]

to your ITemplate property and the

[ParseChildren(true)]
[PersisteChildresn(false)]

to your control class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top