我有一个有几页的网站,我希望这些页面的标题是:
Foo - 1st Page
Foo - 2nd Page
Foo - 3rd Page
我用以下代码创建了一个母版页:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Foo.master.cs" Inherits="Foo" %>
<!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">
<title>Foo - <asp:ContentPlaceHolder ID="SubTitle" runat="server"></asp:ContentPlaceHolder></title>
</head>
<body>
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</body>
</html>
然后每个页面看起来像这样:
<%@ Page Language="C#" MasterPageFile="~/Foo.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="SubTitle" runat="server">1st Page</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<a href="Page2.aspx">Page 2</a>
</asp:Content>
当我在浏览器中加载页面时,我希望标题为Foo - 1st Page
,但它只是1st Page
.
html源代码是:
<!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><title>
1st Page
</title></head>
<body>
<a href="Page2.aspx">Page 2</a>
</body>
</html>
我究竟做错了什么?