模板化控件-开头和结尾标签之间不允许包含内容 [英] Templated Control - content is not allowed between the opening and closing tags

查看:117
本文介绍了模板化控件-开头和结尾标签之间不允许包含内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行MSDN提供的模板化用户控件示例。代码如下:

I'm trying to run the templated user control example provided by MSDN. Code is as follows:

因此,根据MSDN,这应该实现如下:

So according to MSDN this should implement as follows:

<%@ Register Assembly="MyAssembly" Namespace="MyAssembly.Controls" TagPrefix="abs" %>
<abs:TemplatedFirstControl id = "First"  runat=server
                           Text= "The time on the server is "  >
      <FirstTemplate>
          <h3><font face="Verdana" color = "red">
                 <%# Container.Text %> <%# Container.DateTime %>
              </font>
          </h3>
      </FirstTemplate>      
    </abs:TemplatedFirstControl>

Designer抱怨 TemplatedFirstControl的开始和结束标记之间不允许包含内容,并且不支持 FirstTemplate 。那还有什么呢?我逐字复制了MSDN的代码

Designer complains that content is not allowed between the opening and closing tags of TemplatedFirstControl and that FirstTemplate is not supported. So what's missing? I duplicated MSDN's code verbatim

MSDN文章: http://msdn.microsoft.com/zh-CN/library/aa720695%28v=VS.71%29.aspx

推荐答案

对于有相同问题的任何人,我发现在FirstTemplate属性中添加以下属性可以解决以下问题:我:

For anyone who has the same problem, I found that adding the following attributes to the FirstTemplate property solved the issue for me:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public ITemplate FirstTemplate 
{
    get
    {
        return firstTemplate;
    }
    set
    {
        firstTemplate = value;
    }
}

这篇关于模板化控件-开头和结尾标签之间不允许包含内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆