How to call CSS and JavaScript

Source: Internet
Author: User

When we are working on a project, we usually use a large number of master pages. The benefits of using a master page are obvious, but when we nest a master page in the content page, we also need to call CSS styles and JavaScript Functions on the content page. The benefits are met and the problem is also raised. There are two solutions. The first one is to embed all CSS styles and JavaScript Functions in the header CodeMy development environment is Microsoft Visual Studio 2008.

Master Page code:

<% @ Master language = "C #" autoeventwireup = "true" codefile = "indexpage. master. cs"
Inherits = "indexpage" %> <% @ register Assembly = "ajaxcontroltoolkit"
Namespace = "ajaxcontroltoolkit" tagprefix = "PC3" %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml"> <Title> Home page </title> <% -- put the contentplaceholder control here -- %>
<Asp: contentplaceholder id = "head" runat = "server"> </ASP: contentplaceholder>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>

Content Page code:

<% @ Page title = "" Language = "C #" masterpagefile = "~ /Indexpage. Master"
Autoeventwireup = "true" codefile = "companiestest. aspx. cs"
Inherits = "companiestest" %> <asp: Content ID = "content1"
Contentplaceholderid = "head" runat = "server">
<% -- Put the CSS style and JS function to be called in the content control -- %>
<Link href = "CSS/uses.css" rel = "stylesheet" type = "text/CSS"/>
<% -- Put the CSS style and JS function to be called here -- %>
<Link href = "CSS/youle.css" rel = "stylesheet" type = "text/CSS"/>
<Link href = "CSS/slide4.css" rel = "stylesheet" type = "text/CSS"/>
<Link href = "CSS/pointstylesheet.css" rel = "stylesheet" type = "text/CSS"/>
<SCRIPT type = "text/JavaScript" src = "JS/youle. js"> </SCRIPT>
<Link href = "okqq/images/qq.css" rel = "stylesheet" type = "text/CSS"/>
<Script language = 'javascript 'src = 'okqq/serviceqq. js'
Type = 'text/JavaScript 'charset = 'utf-8'> </SCRIPT> </ASP: content>
<Asp: Content ID = "content2" contentplaceholderid = "contentplaceholder1"
Runat = "server"> </ASP: content>

The purpose of inserting CSS styles and JS functions on the content page has been completed.

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.