Phantom Title tag
01/01/2010 Leave a comment
when we are working on refactoring and migration our old project to new one we found a problem with <title> tag . when you look the page source of any page there was always a second empty title element in head tag.
Then we searched all contentplaceholders and client pages with loosing time but we didnt find out why that phantom title tag comming from . After some code work we relized and find out our mistake in contentplaceholder which is defined in head tag in master page of site.
Here is the errors :
Validation (XHTML 1.0 Transitional): Element ‘title’ occurs too many times.
Here is the problematic codes
<head runat=”server”>
<asp:ContentPlaceHolder ID=”head” runat=”server”>
<title> Project Master </title>
</asp:ContentPlaceHolder>
</head>
we fix the problem using coding like this:
<head runat=”server”>
<title>
<asp:ContentPlaceHolder ID=”ctpTitle” runat=”server”>
</asp:ContentPlaceHolder>
</title>
<asp:ContentPlaceHolder ID=”head” runat=”server”>
</asp:ContentPlaceHolder>
</head>