Hi Dennis,
All CSS files placed in Theme folder are loaded automatically for the selected Theme by ASP.Net. Note this is ASP.Net 2.0 feature not Sitefinity’s.
Alternatively you can add CSS links to Sitefinity’s Pages and Templates manually. Go to properties Tab for a Page or a Template and find Add Head Tags section. I suggest using “~” to resolve pats instead of using base tag. This is the common way for ASP.Net applications. So in the HREF field you should specify the path to your CSS file like this “~/styles/myfile.css”.
Anther alternative is to create User Control and place the links to CSS and JavaScript files programmatically like this:
1 |
protected void Page_Load(object sender, EventArgs e) |
2 |
{ |
3 |
// Add Stylesheet |
4 |
System.Web.UI.HtmlControls.HtmlLink link = new System.Web.UI.HtmlControls.HtmlLink(); |
5 |
link.Attributes.Add("rel", "stylesheet"); |
6 |
link.Attributes.Add("type", "text/css"); |
7 |
link.Href = this.ResolveUrl("~/styles/myfile.css"); |
8 |
this.Page.Header.Controls.Add(link); |
9 |
|
10 |
// Add JavaScript |
11 |
string path = this.ResolveUrl("~/Scripts/MyScript.js"); |
12 |
this.Page.ClientScript.RegisterClientScriptInclude("MyScript", path); |
13 |
} |
14 |
|
Images and hyper links should be declared like this:
<img src="~/Images/MyImage.jpg" alt="" runat="server" /> |
<a href="~/SubFolder/Page.aspx" runat="server">My Link</a> |
|
Kind regards,
Slavo
the telerik team