We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

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

carlkelley
carlkelley asked
on
Medium Priority
531 Views
Last Modified: 2012-05-06
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

Comment
Watch Question

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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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.
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.

Author

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?
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.