tags:

views:

74

answers:

1

I use BaseUserControl, where I have a method

private string typeName
{
    get { return GetType().FullName; }
}

private object headOne
{
    get { return Context.Items[typeName + "_Head"]; }
    set { Context.Items[typeName + "_Head"] = value; }
}

public void Head(Action template)
{
    if (headOne == null)
    {
        template();
        headOne = "exist";
    }
}

I use it for now, to not duplicate one user control part. Inside action I have couple Request.Write();

<% Head(() => { %>

<style>.css {}</style>

<% }); %>

What I am interested, hot to execute this Request in a Head tag. For now I didnot find any way, without creating custom view engine.

A: 

Maybe just use masterPages to achieve your purpose . But you can also manipulate System.Web.UI.HtmlControls.HtmlHead Here is a sample

Darkyo