0
我希望有人能幫助我。我有以下的自定義服務器控件:自定義Web控件 - ParseChildren和資源對象
<acme:MyControl runat="sever">
<MyProperty>Test String</MyProperty>
</acme:MyControl>
但是,如果我嘗試本地化屬性字符串,我得到一個解析錯誤:
[ParseChildren(true)]
public class MyControl : WebControl, INamingContainer
{
[PersistenceMode(PersistenceMode.InnerProperty)]
public string MyProperty
{
get;set;
}
}
它具有以下加價完美的作品
<acme:MyControl runat="sever">
<MyProperty><%=(string)GetLocalResourceObject("MyResourceKey") %></MyProperty>
</acme:MyControl>
即使我強制類型,ASP.NET表示屬性不能接受控件作爲子項。如果我想本地化它,表達式應該如何?我可以將該屬性作爲控件標記的屬性訪問,但我更喜歡上面的標記,它看起來更優雅,更乾淨。
感謝
我想這將工作時,控件將只使用一個資源對象在控件的每個實例,但如果字符串可以從另一個方法派生,而不一定從資源對象? – Raybiez 2010-04-21 05:57:55