Add meta tag method to ASP.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.