css not working unless full path given Using Themes .net like BlogEngine.net

Topics: ASP.NET 2.0, Themes
Jul 4, 2008 at 4:58 PM
I am using the same method blogegine.net use for my sites as I am going to be incorperating blogengine into my cms application, however I have one problem i do have the themes working at the basic level were it will take the ur http://localhost/xstreamecms/Default.aspx/?theme=terrafirma 
however for my style sheet to reference right

 

<style type="text/css" media="all">

 

 

@import "../themes/zenlike/default.css";

 

 

</style>

as you can see the above code means i have to use zen like /default.css instead the way blogengine .net just use default.css am i missing something i i.e somewhere else in code where it tells that the css while reside in zenlike as that does not make the template very flexiable.


I have included my fulll base page below in case i am missing something


 

using

System;

 

 

 

using

System.Data;

 

 

 

using

System.Configuration;

 

 

 

using

System.Linq;

 

 

 

using

System.Web;

 

 

 

using

System.Web.Security;

 

 

 

using

System.Web.UI;

 

 

 

using

System.Web.UI.HtmlControls;

 

 

 

using

System.Web.UI.WebControls;

 

 

 

using

System.Web.UI.WebControls.WebParts;

 

 

 

using

System.Xml.Linq;

 

 

 

///

<summary>

 

///

Summary description for XstreamBasePage

 

 

 

///

</summary>

 

 

 

public

class XstreamBasePage :System.Web.UI.Page

 

 

 

{

 

 

private string _Theme;

 

 

//Example variable that can be set for all pages to access

 

 

 

 

private bool bPrintView = false;

 

 

public XstreamBasePage()

 

{

 

//

 

 

 

 

// TODO: Add constructor logic here

 

 

 

 

//

 

 

 

}

 

//db here we are going to set the themes

 

 

 

 

protected override void OnPreInit(EventArgs e)

 

{

 

if (Request.QueryString["theme"] != null)

 

_Theme = Request.QueryString[

"theme"];

 

MasterPageFile = xstreamcms.

Utils.RelativeWebRoot + "themes/" + _Theme + "/site.master";

 

 

base.OnPreInit(e);

 

 

}

 

override protected void OnInit(EventArgs e)

 

{

 

//Always call the base method when override

 

 

 

 

// so what it originally did can still happen

 

 

 

 

base.OnInit(e);

 

 

//Example that just reads a querystring that

 

 

 

 

// should be supported for all pages

 

 

 

 

if (null != Request.QueryString["Print"])

 

{

 

//Use try/catch in case value is not a boolean

 

 

 

 

try

 

 

 

{

bPrintView =

Convert.ToBoolean(Request.QueryString["Print"]);

 

}

 

catch

 

 

 

{

 

//Do nothing, just leave as false

 

 

 

}

}

}

 

 

protected virtual void CompressCss()

 

{

 

if (Request.QueryString["theme"] != null)

 

_Theme = Request.QueryString[

"theme"];

 

 

foreach (Control control in Page.Header.Controls)

 

{

 

HtmlControl c = control as HtmlControl;

 

 

if (c != null && c.Attributes["type"] != null && c.Attributes["type"].Equals("text/css", StringComparison.OrdinalIgnoreCase))

 

{

 

if (!c.Attributes["href"].StartsWith("http://"))

 

{

c.Attributes[

"href"] = xstreamcms.Utils.RelativeWebRoot + "themes/" + _Theme + "/css.axd?name=" + c.Attributes["href"];

 

c.EnableViewState =

false;

 

}

}

}

}

 

protected override void OnLoad(EventArgs e)

 

{

 

base.OnLoad(e);

 

 

if (!Page.IsCallback && !Page.IsPostBack)

 

{

 

 

 

 

}

}

 

protected string BaseURL

 

{

 

get

 

 

 

{

 

try

 

 

 

{

 

return string.Format("http://{0}{1}",

 

 

HttpContext.Current.Request.ServerVariables["HTTP_HOST"],

 

(VirtualFolder.Equals(

"/")) ? string.Empty : VirtualFolder);

 

}

 

catch

 

 

 

{

 

// This is for design time

 

 

 

 

return null;

 

}

}

}

 

/// <summary>

 

 

 

 

/// Returns the name of the virtual folder where our project lives

 

 

 

 

/// </summary>

 

 

 

 

private static string VirtualFolder

 

{

 

get { return HttpContext.Current.Request.ApplicationPath; }

 

}

}