Custom Web Control - ParseChildren & Resource Objects
- by Raybiez
I hope someone can help me. I have the following custom server control:
[ParseChildren(true)]
public class MyControl : WebControl, INamingContainer
{
[PersistenceMode(PersistenceMode.InnerProperty)]
public string MyProperty
{
get;set;
}
}
It works perfectly with the following mark-up:
<acme:MyControl runat="sever">
<MyProperty>Test String</MyProperty>
</acme:MyControl>
But if I try to localise the property string, I get a parse error:
<acme:MyControl runat="sever">
<MyProperty><%=(string)GetLocalResourceObject("MyResourceKey") %></MyProperty>
</acme:MyControl>
Even if I cast the type, ASP.NET indicates that the property cannot accept controls as children. How should the expression look like if I want to localise it? I can make the property accessible as an attribute of the control's tag, but I prefer the mark-up above, it looks more elegant and clean.
Thanks