ASP. Add meta tag method including KEYWORDS,CSS, JS
Here is the addition of CSS, JS, meta tags from the ASP, we write a function here for later use. If the function is placed in a page class, it is also possible to do so by page parameters.
First import namespaces using System.Web.UI.HtmlControls;
The code is as follows:
/// ///Add JS script link/// ///page///Path Public voidAddjs (System.Web.UI.Page Page,stringURL) {HtmlGenericControl Jscontrol=NewHtmlGenericControl ("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 voidAddscript (System.Web.UI.Page Page,stringcontent) {HtmlGenericControl ScriptControl=NewHtmlGenericControl ("Script"); SCRIPTCONTROL.ATTRIBUTES.ADD ("type","Text/javascript"); Scriptcontrol.innerhtml=content; page. HEADER.CONTROLS.ADD (ScriptControl); } /// ///Add CSS style links/// ///page///Path Public voidAddcss (System.Web.UI.Page Page,stringURL) {Htmllink link=Newhtmllink (); 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 voidAddstyle (System.Web.UI.Page Page,stringcontent) {HtmlGenericControl Stylecontrol=NewHtmlGenericControl ("style"); STYLECONTROL.ATTRIBUTES.ADD ("type","Text/css"); Stylecontrol.innerhtml=content; page. HEADER.CONTROLS.ADD (Stylecontrol); } /// ///Add META Tags/// ///page///meta name///meta content Public voidAddmeta (System.Web.UI.Page Page,stringNamestringcontent) {Htmlmeta meta=NewHtmlmeta (); Meta. Name=name; Meta. Content=content; page. HEADER.CONTROLS.ADD (meta); }
This tutorial is from the Web development tutorial www.114390.com
Add meta tag method to ASP.