1
我創建了一個自定義控件,它需要一個自定義模板。但沒有intellisense的支持,並有這個xhtml錯誤。 自定義服務器控件 - 如何獲得智能感知支持並清除xhtml錯誤?
我檢查了一些問題; this文章說,我們必須得到它默認情況下。不過,我一直沒有得到它。我錯過了什麼嗎?
這是怎樣的代碼看起來像:
服務器控制:
[ToolboxData("<{0}:CustomTemplateControl runat=server></{0}:CustomTemplateControl>")]
[Description("My Custom Template Control")]
public class CustomTemplateControl : WebControl
{
[TemplateContainer(typeof(CustomTemplateItem))]
public ITemplate CustomHeader { get; set; }
protected override void CreateChildControls()
{
if (CustomHeader != null)
{
CustomHeader.InstantiateIn(this);
}
base.CreateChildControls();
}
public override void RenderBeginTag(HtmlTextWriter writer)
{
writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID);
writer.RenderBeginTag(HtmlTextWriterTag.Label);
//base.RenderBeginTag(writer);
}
模板:
public class CustomTemplateItem : Control, INamingContainer
{
}