User Control/Server Control中Inner Text (Literal Content)属性设置

来源:互联网 发布:软件破解 编辑:程序博客网 时间:2024/06/05 06:37
在自建UserControl或者ServerControl过程中我们常常遇到需要调用<tag>Text</tag>中的Text值。如果不指明,asp.net会抛出 Literal Content is not allowed 错误。网上资料不多,最方便的方法是在UserControl类加上属性:

[ParseChildren(true,"<Default Property>")
]

<Default Property>是Text被指定的Property name。就这么简单。
原创粉丝点击