ASP.Net Themes


I would like to use ASP.Net themes on my EPiServer site - I have given the web editor a drop down with a list of available themes to choose from.

However, there seems to be an issue with ASP.Net themes and the EPiServer URLRewriter not rebasing the generated CSS links.

i.e. the link generated by ASP.Net is relative to the physical path rather than the generated path.


URL Page Type Physical Location generated link
http://localhost:6667/ Project\Default.aspx <link href="App_Themes/theme/style.css" type="text/css" rel="stylesheet" />
http://localhost:6667/PageLevel1/ Project\Templates\Public\Pages <link href="../../../App_Themes/theme/style.css" type="text/css" rel="stylesheet" />
http://localhost:6667/PageLevel1/PageLevel2/PageLevel3/ Project\Templates\Public\Pages <link href="../../../App_Themes/theme/style.css" type="text/css" rel="stylesheet" />
http://localhost:6667/PageLevel1/PageLevel2/PageLevel3/PageLevel4 Project\Templates\Public\Pages <link href="../../../App_Themes/theme/style.css" type="text/css" rel="stylesheet" />

Has anyone tried this before and come across a solution?

Any help / ideas for a solution would be apprciated.


Aug 03, 2010 12:37

Okay so fixed it!

I coded a control adapter to set the href correctly.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace JR.EPI.OAPMain.WebForms.ControlAdapters
    public class LinkControlAdapter: System.Web.UI.Adapters.ControlAdapter 
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
            System.Web.UI.HtmlControls.HtmlLink HL = this.Control as System.Web.UI.HtmlControls.HtmlLink;
            if (HL != null)
                HL.Href = VirtualPathUtility.ToAbsolute(HL.Href);

and added a browser file in App_Browser folder.

    <browser refID="Default">
        <adapter controlType="System.Web.UI.HtmlControls.HtmlLink"
                 adapterType="JR.EPI.OAPMain.WebForms.ControlAdapters.LinkControlAdapter, JR.EPI.OAPMain.WebForms, Culture=neutral, PublicKeyToken=null" />

Not sure why VirtualPathUtility.ToAbsolute(HL.Href) works where the HtmlLink's RenderAttributes call to REsolveClientUrl does not but hey as long as it works right!


Aug 03, 2010 15:20
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.