Add CSS and JS labels in the background

Source: Internet
Author: User

 

# Region # Add a JS File

/// <Summary>

/// Add a JS File

/// Created by porschev

/// Creation Time: 2011-7-25

/// </Summary>

/// <Param name = "page"> page </param>

/// <Param name = "url"> path </param>

Public void addscript (system. Web. UI. Page, string URL)

{

Htmlgenericcontrol jscontrol = new htmlgenericcontrol ("script ");

Jscontrol. Attributes. Add ("type", "text/JavaScript ");

Jscontrol. Attributes. Add ("src", URL );

Page. header. Controls. Add (jscontrol );

}

# Endregion

# Region # Add a CSS file

/// <Summary>

/// Add a CSS file

/// Created by: posrchev

/// Creation Time: 2011-7-25

/// </Summary>

/// <Param name = "page"> page </param>

/// <Param name = "url"> path </param>

Public void addcss (system. Web. UI. Page, string URL)

{

Htmllink csscontrol = new htmllink ();

Csscontrol. href = URL;

Csscontrol. Attributes. Add ("rel", "stylesheet ");

Csscontrol. Attributes. Add ("type", "text/CSS ");

Page. header. Controls. Add (csscontrol );

}

# Endregion

# Region # Add a meta tag

/// <Summary>

/// Add a meta tag

/// Created by: posrchev

/// Creation Time: 2011-7-25

/// </Summary>

/// <Param name = "page"> page </param>

/// <Param name = "name"> name </param>

/// <Param name = "content"> body </param>

Public void addmeta (system. Web. UI. Page, string name, string content)

{

System. Web. UI. htmlcontrols. htmlmeta meta = new system. Web. UI. htmlcontrols. htmlmeta ();

Meta. Name = Name;

Meta. content = content;

Page. header. Controls. Add (Meta );

}

# Endregion

 All three methods can be placed in the public class. If they are directly placed in the page class, the page parameter may not

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.