我已经创建了一个字符串InnerProperty服务器控件(不是用户控制......没有ASCX):在自定义服务器控件使用eval()InnerProperty
[PersistenceMode(PersistenceMode.InnerProperty)]
[BindableAttribute(true)]
public string LabelText {
get { return Label.Text; }
set { Label.Text = value; }
}
当给定一个普通字符串标记它工作正常:
<Custom:SpecialTextBox ID="Box" runat="server" >
<LabelText>
Some Text
</LabelText>
</Custom:SpecialTextBox>
如果我使用该控件的数据绑定控件(例如ListView控件),并希望使用Eval方法在InnerProperty:
<Custom:SpecialTextBox ID="Box" runat="server" >
<LabelText>
Some <%# Eval("TextType") %> Text
</LabelText>
</Custom:SpecialTextBox>
我收到一个解析器错误:
The 'LabelText' property of 'Custom:SpecialTextBox' does not allow child objects.
有没有办法,我可以把属性,使这项工作的一个属性或东西吗?谢谢。
当你将LabelText的到EVAL直列会发生什么,例如' Custom:SpecialTextBox>'? –
@DaveZych这有点奇怪:你建议的作品,但如果我想结合它与静态文本(LabelText ='一些<%#Eval(“TextType”)%>文字')Eval不评估。 – kad81
如果只有LabelText元素中没有某些文本字的Eval,那么怎么办? –