There are many ways to skin a Web page, and the simplest is usually to switch between CSS and CSS, which is usually written in an external CSS file. Then switching CSS is actually replacing the link href path in HTML. I searched the internet for the next.
There are generally two ways:
1. Put a holder control on the page. Then programmatically write the current user's style CSS link to the page.
2. Over-reflection mechanism, set CSS style on a per-control basis.
The above two ways are very troublesome, the first need to put a holder control on each page, similar to the practice of adding link tag runat=server, page more, are more troublesome. The second is not considered, performance programming efficiency is a lot of problems.
Remember in the past when learning Dnn, in him found a change in the form of the default action address of the way, directly under the reference. Not bad:
Overriding the render event directly
protected override void Render (System.Web.UI.HtmlTextWriter writer)
{
StringWriter SW = new StringWriter ();
HtmlTextWriter htmlwriter = new HtmlTextWriter (SW);
Base. Render (HTMLWriter);
Current user-selected style CSS
String css = "<link href=" CSS url "rel=" stylesheet "type=" text/css ">";
string html = sw. ToString ();
int startPoint = HTML. IndexOf ("if (StartPoint > 0)
{
html = HTML. Insert (StartPoint, CSS);
}
Writer. Write (HTML);
}
Put this in the base class pagebase of each page. That's a lot easier.
Of course, if you don't want to let each page inherit the custom base class, it can also be written in HttpModule. Also very convenient, a place to write well, page useful ah.
Asp. NET rewrite render to load CSS style files and JS files (toggle css for skin)