CSS uses the master page's content page to invoke CSS and JavaScript

Source: Internet
Author: User

Programme one:

Putting all the CSS styles and JavaScript functions into the

Scenario Two:

The CSS file for this content page is specified by code in the Pageload event of the content page.

The code is as follows

static public class Controlhelper
{
static public void Addstylesheet (Page page, string csspath)
{
Htmllink link = new Htmllink ();
Link. Href = Csspath;
Link. attributes["rel"] = "stylesheet";
Link. attributes["type"] = "text/css";
Page. HEADER.CONTROLS.ADD (link);
}
}

On a specific page, we can add a CSS reference with the following code:

protected void Page_Load (object sender, EventArgs e)
{
Controlhelper.addstylesheet (this. Page, "Css/projectpage.css");
}

The benefit of this solution is that you can dynamically change the desired CSS file while the program is running, but how do you do it with JavaScript functions? Is it necessary to add the CSS and JavaScript that should be added to the HTML code through the CS code?

Programme III:

Add a ContentPlaceHolder control to the , and then write CSS and JavaScript code in the content page for the corresponding content control.

CSS uses the master page's content page to invoke CSS and JavaScript

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.