There are many web site readers can change their favorite style, and some sites want to multi-site sharing back-end code and only move the former paragraph style, you can use the dynamic replacement of CSS style and JS. If you are developing WebForm, you can use the following methods:
The process is to first read the data from the data or XML, and then assign the value to the front page
HTML <meta> Tag Additions
Htmlmeta mtdes = new Htmlmeta ();//new instance
Mtdes. Name = "Description";//Label
Mtdes. Content = this. descriptionp;//Content
HEADER.CONTROLS.ADD (mtdes); adding CSS Properties
HTML <Link> tag Additions, which is the key to dynamically adding CSS styles
Htmllink hlk = new Htmllink ();//new instance
Hlk. Href = "CSS/A.CSS";//Add CSS Address
Hlk. Attributes.Add ("rel", "stylesheet");//Add CSS Properties
Hlk. Attributes.Add ("type", "text/css");//Add CSS Property
HEADER.CONTROLS.ADD (HLK);//Add to the page header control
Same as below:
Htmllink csslink2 = new Htmllink ();
Csslink2. Href = "Css/css1.css";
Csslink2. Attributes.Add ("rel", "stylesheet");
Csslink2. Attributes.Add ("type", "text/css");
HEADER.CONTROLS.ADD (CSSLINK2);
Add JS Dynamically
HtmlGenericControl Jslink = new HtmlGenericControl ("script"); Create a new script instance
Jslink. attributes["type"] = "text/javascript";//Mark JS text category
Jslink. attributes["src"] = "js/elf.js";//js's URL address
HEADER.CONTROLS.ADD (Jslink); Add to Page Header control
Add title and Description
This. Titlep = dr["title"]. ToString ();
This. Descriptionp = dr["Breif"]. ToString ();
This. Label3.text = dr["title"]. ToString ();
This. Label4.text = dr["about"]. ToString ();
Page.title = Titlep; Add heading Mode 2
In fact, there are a lot of methods, we can expand their thinking in other ways to achieve.
If you have any questions about the above article, please treatise
Asp. NET to the front-end dynamic add modify CSS style JS title keyword