我已經創建了一個字符串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,那麼怎麼辦? –