Code block + literal in asp.net custom control
<p>I'm searching for 2 days now to accomplish the following:
I want a custom control which will take inline text + code blocks.</p>

<p>Example of what I want to achieve:</p>

<pre><code>&lt;asp:MyCustom runat="server"&gt;
    Hello there, &lt;%= User.Name%&gt;
&lt;/asp:MyCustom&gt;
</code></pre>

<p>Here is what I currently have:</p>

<pre><code>[ParseChildren(true), PersistChildren(true)]
public class MyCustom
{
    [PersistenceMode(PersistenceMode.InnerDefaultProperty)]
    public ITemplate Text { get; set; }

    //Constructor
    public MyCustom()
    {
        Text = new StringITemplate(text);
    }
}
</code></pre>

<p>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.</p>

<p>Ultimately, I want to achieve the following:</p>

<pre><code>&lt;asp:MyCustomItemControl runat="server"&gt;
    &lt;Items&gt;
        &lt;asp:Item&gt;Hello there, &lt;%= User.Name%&gt;&lt;/asp:Item&gt;
        &lt;asp:Item&gt;&lt;%= SomeOtherString%&gt;&lt;/asp:Item&gt;
    &lt;/Items&gt;
&lt;/asp:MyCustom&gt;
</code></pre>

<p>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.</p>

<p>The complete code of what I have right now, can be looked at here:
<a href="http://pastebin.com/3gic2Y0u" rel="nofollow">http://pastebin.com/3gic2Y0u</a></p>

<p>Thanks for reading :)</p>
