Asp.net|css
There are many ways to change skin, the simplest is usually to switch page CSS, and CSS is usually written in the external CSS file. Then switch CSS is actually the replacement HTML link href path. I searched the internet for the next. There are generally two ways:
1, put a holder control on the page. The current user's style CSS link is then written to the page programmatically.
2, through the reflection mechanism, the CSS style is set individually.
Both of these ways are troublesome,
The first one needs to put a holder control on each page. A similar approach is to add runat=server to the link tag. More pages, more trouble.
The second is out of the consideration. There are a lot of problems with performance programming efficiency.
Remember before learning Dnn, in him found a way to modify the default action address in the form, direct reference. Not bad:
overriding render events directly
Copy C # source code 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 would be a lot more convenient.
Of course, if you don't want each page to inherit a custom base class, you can also write it in HttpModule. is also very convenient.
A place to write, the page is good.