There are many website readers who can change the style they like, and some websites want to share the back-end code with multiple sites and only change the front-end style. You can use dynamic replacement of CSS style and JS. If it is webform development, you can use the following methods:
The process is to first read the data from the data or xml, and then assign it to the front-end page
HTML <meta> tag added
HtmlMeta mtdes = new HtmlMeta();//New instance
mtdes.Name = "Description";//label
mtdes.Content = this.Descriptionp;//content
Header.Controls.Add(mtdes); Add css attributes
Add HTML <Link> tag, which is the key to dynamically add CSS style
HtmlLink hlk = new HtmlLink();//New instance
hlk.Href = "css/a.css";//add css address
hlk.Attributes.Add("rel","stylesheet");//Add css attributes
hlk.Attributes.Add("type","text/css");//Add css attributes
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);
Dynamically add JS
HtmlGenericControl jslink = new HtmlGenericControl("script"); Create a new script instance
jslink.Attributes["type"] = "text/javascript";//mark the js text category
jslink.Attributes["src"] = "js/elf.js";//JS URL address
Header.Controls.Add(jslink); //Add to the 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 title method 2
In fact, there are many ways, and you can expand your thinking and implement it in other ways.
If there is any problem with the above article, please correct me