Hi,
Here's the code for a simple content usercontrol I am using:
and the markup is:Code:public partial class ContentPanel : System.Web.UI.UserControl { [ParseChildren(true, "ContentTemplate")] public class ContentContainer : Control, INamingContainer {} private ITemplate _contentTemplate; [TemplateContainer(typeof(ContentContainer), BindingDirection.TwoWay)] [PersistenceMode(PersistenceMode.InnerProperty)] [TemplateInstance(TemplateInstance.Single)] [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] [EditorBrowsable(EditorBrowsableState.Never)] public ITemplate ContentTemplate { get { return this._contentTemplate; } set { this._contentTemplate = value; } } protected override void OnInit(EventArgs e) { base.OnInit(e); if(this._contentTemplate != null) { ContentContainer container = new ContentContainer(); this._contentTemplate.InstantiateIn(container); this.phContentTemplate.Controls.Add(container); } } }
So in every page i use this the markup would be like:Code:<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ContentPanel.ascx.cs" Inherits="SvratchJScriptWeb.UserControls.ContentPanel" %> <div id="divPanel" runat="server" style="width:300px"> <asp:PlaceHolder ID="phContentTemplate" runat="server" /> </div>
This works at runtime...however the control fails to render at design time with the error:Code:<uc1:ContentPanel ID="ContentPanel1" runat="server"> <ContentTemplate> other controls and stuff goes here </ContentTemplate> </uc1:ContentPanel>
Error Creating Control - ContentPanel1
Type 'System.Web.UI.UserControl' does not have a public property named 'ContentTemplate'
The odd thing is that the VS IDE intellisence can see that the template is called <ContentTemplate> and hightlights it when I type into the UI source designer...it just fails when looking at design time rendering :s
Has anyone seen this b4?
Woka


Reply With Quote

