Hello,
I am just experimenting with master pages, and am trying to add a
content placeholder in the <head> section, so that individual pages can
set their own page title and meta tags. The master page looks like
this...
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<asp:ContentPlaceHolder ID="cphHead" runat="server" />
</head>
<body>
.... other stuff with content placeholders here...
</body>
</html>
A page that uses this master would have content controls for the
placeholder in the header, as well as the others in the body (not
shown). For example (partial code for a sample .aspx page shown)...
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="About.aspx.cs"
Inherits="About" Title="Untitled Page" debug="true"
MasterPageFile="MasterPageToys.master" %>
<asp:Content ID="cntHead" ContentPlaceHolderID="cphHead" Runat="Server">
<title>Test Page Using Master Pages</title>
<meta name="keywords" content="stuff, nonsense, master pages, asp.net">
<meta name="description" content="This is a page using master pages,
etc">
</asp:Content>
....other content controls here...
The problem is that when the page is rendered, ASP.NET adds another
<title> tag, giving invalid HTML like this...
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Test Page Using Master Pages</title>
<meta name="keywords" content="stuff, nonsense, master pages, asp.net">
<meta name="description" content="This is a page using master pages,
etc">
<title>
Untitled Page
</title></head>
<body>
Is there any way to stop it doing this, or am I going about this the
wrong way? Any comments appreciated.
--
Alan Silver
(anything added below this line is nothing to do with me)