The following is from the asp.net background to add CSS, JS, meta tags of the writing, we write here to facilitate the use of functions. If the function is placed in the page class, the page parameter is also not available.
First, the namespace using System.Web.UI.HtmlControls is imported;
 
 
  
  Copy Code code as follows: 
 
 
  
 
 
/// 
 
Add JS Script link 
 
/// 
 
Page 
 
Path 
 
public void Addjs (System.Web.UI.Page Page, string url) 
 
{ 
 
HtmlGenericControl Jscontrol = new HtmlGenericControl ("script"); 
 
JSCONTROL.ATTRIBUTES.ADD ("type", "Text/javascript"); 
 
JSCONTROL.ATTRIBUTES.ADD ("src", url); 
 
Page. HEADER.CONTROLS.ADD (Jscontrol); 
 
} 
 
 
 
 
 
/// 
 
Add JS script content 
 
/// 
 
Page 
 
Script Content 
 
public void Addscript (System.Web.UI.Page Page, string content) 
 
{ 
 
HtmlGenericControl ScriptControl = new HtmlGenericControl ("script"); 
 
SCRIPTCONTROL.ATTRIBUTES.ADD ("type", "Text/javascript"); 
 
scriptcontrol.innerhtml = content; 
 
Page. HEADER.CONTROLS.ADD (ScriptControl); 
 
} 
 
 
 
 
 
/// 
 
Add CSS style Links 
 
/// 
 
Page 
 
Path 
 
public void Addcss (System.Web.UI.Page Page, string url) 
 
{ 
 
Htmllink link = new Htmllink (); 
 
Link. Href = URL; 
 
Link. Attributes.Add ("rel", "stylesheet"); 
 
Link. Attributes.Add ("type", "text/css"); 
 
Page. HEADER.CONTROLS.ADD (link); 
 
} 
 
 
 
 
 
/// 
 
Add CSS style content 
 
/// 
 
Page 
 
Style content 
 
public void Addstyle (System.Web.UI.Page Page, string content) 
 
{ 
 
HtmlGenericControl Stylecontrol = new HtmlGenericControl ("style"); 
 
STYLECONTROL.ATTRIBUTES.ADD ("type", "text/css"); 
 
stylecontrol.innerhtml = content; 
 
Page. HEADER.CONTROLS.ADD (Stylecontrol); 
 
} 
 
 
 
 
 
/// 
 
Add META Tags 
 
/// 
 
Page 
 
Meta name 
 
Meta content 
 
public void Addmeta (System.Web.UI.Page Page, string name, string content) 
 
{ 
 
Htmlmeta meta = new Htmlmeta (); 
 
Meta. name = name; 
 
Meta. Content = content; 
 
Page. HEADER.CONTROLS.ADD (meta); 
 
}