Groups | Blog | Home
all groups > asp.net webcontrols > december 2005 >

asp.net webcontrols : Templated User Control & intellisense


Frédéric Mayot
12/12/2005 10:10:40 PM
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>

Brock Allen
12/13/2005 4:56:49 AM
You also need to apply
[PersistenceMode(PersistenceMode.InnerProperty)]]

to your ITemplate property and the

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

to your control class.

-Brock
DevelopMentor
http://staff.develop.com/ballen

[quoted text, click to view]

AddThis Social Bookmark Button