添加第二个名为
MyPropertyResourceKey
[ParseChildren(true)]
public class MyControl : WebControl, INamingContainer
{
[PersistenceMode(PersistenceMode.InnerProperty)]
public string MyProperty
{
get;set;
}
string _propertyResourceKey;
[PersistenceMode(PersistenceMode.InnerProperty)]
public string MyPropertyResourceKey
{
get {
return _propertyResourceKey;
}
set {
_propertyResourceKey = value;
MyProperty = (string)GetLocalResourceObject(_propertyResourceKey);
}
}
}
编辑:
根据评论,似乎还需要一种更灵活的方法。通常,如果您要为控件分配动态值,则需要创建数据绑定控件(如果适用)
http://msdn.microsoft.com/en-us/library/ms366540.aspx
.