Reference Javascript and Css classes in the background

Source: Internet
Author: User

Javascript and Css are usually referenced in the

Write a class that references Javascript and Css in the background

/// <Summary> /// Add the JS script link /// </summary> /// <param name = "page"> page </param> /// <param name = "url"> path </param> public static 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 );} /// <summary> /// Add the JS script content /// </summary> /// <param name = "page"> page </param> /// <param name = "content"> script content </param> public static 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 );} /// <summary> /// Add a CSS style link /// </summary> /// <param name = "page"> page </param> /// <param name = "url"> path </param> public static 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 );} /// <summary> /// add CSS style content /// </summary> /// <param name = "page"> page </param> /// <param name = "content"> style content </param> public static 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 );} /// <summary> /// add Meta tag /// </summary> /// <param name = "page"> page </param> /// <param name = "name"> HttpEquiv </param> // <param name = "content"> Meta content </param> public static void AddMeta (System. web. UI. page page, string name, string content) {HtmlMeta meta = new HtmlMeta (); meta. httpEquiv = name; meta. content = content; page. header. controls. add (meta );}

 

Related Article

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.