I'm searching for 2 days now to accomplish the following: I want a custom control which will take inline text + code blocks.
Example of what I want to achieve:
<asp:MyCustom runat="server">
Hello there, <%= User.Name%>
</asp:MyCustom>
Here is what I currently have:
[ParseChildren(true), PersistChildren(true)]
public class MyCustom
{
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public ITemplate Text { get; set; }
//Constructor
public MyCustom()
{
Text = new StringITemplate(text);
}
}
On top of that, the control is actually a member of a list of a parent user control that inherits from "UserControl", overrides the Render method. Also, there is a class StringITemplate, which allows assigning plain strings to the ITemplate property as well.
Ultimately, I want to achieve the following:
<asp:MyCustomItemControl runat="server">
<Items>
<asp:Item>Hello there, <%= User.Name%></asp:Item>
<asp:Item><%= SomeOtherString%></asp:Item>
</Items>
</asp:MyCustom>
Right now, I would be happy if my first request actually worked. Seems like hell to get a grip on the wilderness of web/user/custom/server - controls in asp.net and their properties.
The complete code of what I have right now, can be looked at here: http://pastebin.com/3gic2Y0u
Thanks for reading :)