• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 522
  • Last Modified:

Why doesn't ASP.NET close the meta tag defined in my MasterPage?

I have a MasterPage that starts off as shown below.  As you can see, the meta tag is closed.  But, when a page that references the MasterPage is rendered, the metatag is open thus causing an HTML validation error.  What must I do to get ASP.NET to render the meta tag closed?
<%@ master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage1.Master.cs"
    Inherits="MyCompany.MyApp.MasterPage1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Copyright 1999-2009, MyCompany Corporation, all rights reserved, http://www.MyCompany.com -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>MyCompany/MyApp: My System</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <link href="~/Styles/styles.css" rel="stylesheet" type="text/css" runat="server" />
    <asp:contentplaceholder ID="head" runat="server">
    </asp:contentplaceholder>
</head>
<body>

Open in new window

0
carlkelley
Asked:
carlkelley
  • 2
  • 2
1 Solution
 
Ramone_HamiltonCommented:
Usually this has to be done programmatically but you can save yourself a little bit of a headache by placing it within another content placeholder.
<asp:ContentPlaceHolder ID="MyMetaData" ruat="server">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</asp:ContentPlaceHolder>

Open in new window

0
 
carlkelleyAuthor Commented:
Thanks, Ramone.  I did not know that one could add content to a placeholder inside a MasterPage.  If you feel like explaining why this works, I'd like to know.
0
 
Ramone_HamiltonCommented:
The reason you want to place conten within the content place holder within the masterpage is if you want something to be static amongst all pages, just like your meta data.  You also might want to do this if you've created a web user control as a side bar that you want to show up on every page.
0
 
carlkelleyAuthor Commented:
I appreciate that you answered my question after all points were awarded.  What is puzzling me is this:  Everything OUTside the placeholders in a MasterPage is shared between the pages that inherit the MasterPage.  Why is there a need to put shared content INside the placeholders in a MasterPage?  And why is shared content placed inside placeholders rendered differently than outside content?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now