我是一位.NET MVC初学者 我用的是VS2010 MVC2 现在碰见一个问题 在母版页中创建的内容页 想调用一个CSS样式不懂怎么调用在网上查了一下
说是在母版页的<head></head>中写一个
<asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder>
然后在内容页里面写一个<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">控件
就可以实现外调CSS了
以下是我的代码:
内容页:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/ViewMasterPage1.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content4" ContentPlaceHolderID="head1" Runat="Server">
<link href="../../Content/bbs1.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="view">
</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
</asp:Content>
母版页:
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<!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" >
<head runat="server">
<asp:ContentPlaceHolder id="head1" runat="server"> </asp:ContentPlaceHolder>
<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
<link href="../../Content/bbs1.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="menubar">
<h1 style="width: 1085px">My Website</h1>
<div id="bar">
<div id="bar1">
<ul id="ul1">
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
</ul>
</div>
<div id="bar2">
</div>
</div>
</div>
<div id="column">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="column">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</div>
</body>
</html>
CSS内容:
#menubar
{height:300px;
width:100%;
background:#FF0000;
}
#menubar.h1{}
#bar
{width:100%;
height:50px;
background:#00008B;
margin-top:215px;
padding-bottom:0px;
}
#bar1
{ width:80%;
height:50px;
background:#FF00FF;
}
/*#bar2
{width:auto;
heigth:50px;
background:#FFD700
}*/
#ul1
{height:50px;
}
#bar1 li
{float:left;
position:inherit;
width:20%;
height:50px;
}
#column
{width:100%;
background:#FFFF00;
height:600px;
}
#ContentPlaceHolder
{height:200px;
}
#view
{height:200px;
background:#FFFF00;
}
以下是错误提示:
请各位大虾指点一下 我想在MVC母版的内容页中调用CSS或者JS的话 该如何实现 谢谢