Put C# variable as parameter on ASP .NET custom control
<p>I have this code in my ASP page:</p>

<pre><code>&lt;%@ Register TagPrefix="genies" Namespace="TheNamespace" Assembly="TheAssembly"%&gt;

...

&lt;% string name = GetTag().Name; %&gt;
&lt;div class="&lt;%= name %&gt;"&gt;&lt;/div&gt;
&lt;genies:BarGenie ID="BarGenie1" runat="server" Title="&lt;%= name %&gt;" /&gt;
</code></pre>

<p>The BarGenie class has the following code:</p>

<pre><code>public class BarGenie : Control {

    public string Title { get; set; }

    protected override void Render(HtmlTextWriter writer) {
        writer.Write("&lt;div&gt;" + Title + "&lt;/div&gt;");
    }

}
</code></pre>

<p>This is the HTML that is generated:</p>

<pre><code>&lt;div class="E00383"&gt;&lt;/div&gt;
&lt;div&gt;&lt;%= name %&gt;&lt;/div&gt;
</code></pre>

<p>I'd like to see this HTML:</p>

<pre><code>&lt;div class="E00383"&gt;&lt;/div&gt;
&lt;div&gt;E00383&lt;/div&gt;
</code></pre>

<p>I've tried various things in the ASPX code: @name, &lt;%# name %> etc but I can't figure out what's going on. Is there some other way of inserting a custom control that I should be using? Do I have the wrong approach to using this custom control?</p>
