I am building a product that we are eventually going to white-label. Right now I am trying to figure out the best way to facilitate these requirements programmatically so th
I like the idea of using dynamic CSS using an ASP.Net Handler...
<link rel="stylesheet" href="style.ashx" />
style.ashx
<!--WebHandler Language="C#" Class="StyleSheetHandler"-->
StyleSheetHandler.cs
public class StyleSheetHandler : IHttpHandler {
public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "text/css";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
string css = BuildCSSString(); //not showing this function
context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(600));
context.Response.Cache.SetCacheability(HttpCacheability.Public);
context.Response.Write( css );
}
public bool IsReusable
{
get { return true; }
}
}
The BuildCSSString() Function will build the css based on the values stored in the database and return it to override the base style on the master page.
I would avoid using the !important clause and instead just ensure their values appear in a <style>
tag following the import of the regular style sheets.
Otherwise, I would do it the same way.