How to Add Element between <Head> tags

G

Guest

How can I add the following element to the <Head> section of every page?

<link href="Styles/main.css" type="text/css" rel="stylesheet">

I would like to do this in my Page base class (in the overridden Render
method perhaps?) rather than adding the tag to each page.

Or is there a better way of applying this css to every page.


Thanks
 
G

Guest

in Page.aspx:
<head runat="server" id="header">
<title>Untitled Page</title>
</head>

// codebehind:

protected void Page_Load(object sender, EventArgs e)
{
HtmlLink link = new HtmlLink();
link.Attributes.Add("type", "text/css");
link.Attributes.Add("rel", "stylesheet");
link.Attributes.Add("href", "~/styles/main.css");
this.header.Controls.Add(link);

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top