1 回答
TA贡献1856条经验 获得超17个赞
母版页应如下所示:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs"
Inherits="MasterPage" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<%--all meta tags--%>
<%--all scripts put here will be available to every page that uses this master.--%>
<asp:ContentPlaceHolder id="head" runat="server">
<%--note this content placeholder in the head. don't put anything in it yet.
it will be available to pages that use this master.--%>
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
<%--add script tags and links-to-js before the closing body tag.
they will be available to every page that uses this master page.--%>
</body>
</html>
使用母版页的表单将如下所示:
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<%--this is the content placeholder from the head of the master.
add styles and links-to-css for use on just this page.--%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
content for this page.
<%--add scripts for just this page.--%>
</asp:Content>
- 1 回答
- 0 关注
- 194 浏览
添加回答
举报