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.