Request.Write - execute in the Head tag. [Action - Templates]

I am using 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 am using it now to avoid duplicating one part of the user control. Inside the activity, I have a couple Request.Write ();

<% Head(() => { %>

<style>.css {}</style>

<% }); %>

      

I am wondering hotly to fulfill this request in the Head tag. So far I haven't found any way without creating a custom view engine.

0


source to share


1 answer


Maybe just use masterPages to achieve your goal. But you can also manipulate System.Web.UI.HtmlControls.HtmlHead

Here is an example



0


source







All Articles