Design and CSS styles
Version 5.x > Design and CSS styles > Automatic style sheet inclusion? View modes: 
User avatar
Member
Member
chris.percival-oakwood-dc - 3/26/2010 6:29:30 AM
   
Automatic style sheet inclusion?
I don't really understand why I can appear to control what stylesheet my (aspx) site uses, when I still have to put
<link href="~/CMSPages/GetCSS.aspx?stylesheetname=mystylesheet" type="text/css" rel="stylesheet" />
in the master page? Unless there is some control or API call I can make to pull in the correct stylesheet?

Thanks

Chris

User avatar
Member
Member
chris.percival-oakwood-dc - 4/1/2010 6:25:58 AM
   
RE:Automatic style sheet inclusion?
I was being hasty. TemplateMasterPage.HeaderTags will contain an html link to the current stylesheet, so setting a literal in the head section of your masterpage will ensure that the link is included in the page. You don't need to explicitly include it as I have suggested above.

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 4/1/2010 3:50:08 PM
   
RE:Automatic style sheet inclusion?
Hello,

The GetCSS script automatically loads the stylesheet in the parameter. In case of using Portal Engine approach, it's automatically updated in Master page definition.

If you use ASPX templates approach you can follow instructions on Creating ASPX master pages and use following code that automatically links the selected Site stylesheet (and meta-tags) in the page header:


<head id="Head1" runat="server">
<asp:literal runat="server" id="ltlTags" enableviewstate="false" />
</head>

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
this.ltlTags.Text = this.HeaderTags;
}


Best regards,
Zdenek C.