Vijjendra
Vijjendra

Reputation: 25233

<title></title> tag occurs two time on Page

I have set the Page title dynamically. When I look the page source in that the <title> tag occurs two time, one tag have the value which I have set dynamically just below the <head> start, but another is blank just before the </head>. In master page head tag contains below code:

<head runat="server">
<asp:ContentPlaceHolder ID="pageTitle" runat="server"></asp:ContentPlaceHolder>

<asp:ContentPlaceHolder ID="head" runat="server">       
</asp:ContentPlaceHolder>

</head>

on Page I have set the Page title like:

 var title = new HtmlTitle {Text = title1};
  var h1Tag = Utilities.FindControlRecursive(this, "pageTitle");// by the find the pageTitle control 
   if (h1Tag != null)
   {
      h1Tag.Controls.Add(title);
    }

I am not able to figure out why the title occurs twice. I also want to put metakeyword,metadescription and title just below the <head> tag.

Upvotes: 0

Views: 287

Answers (1)

Adrian Iftode
Adrian Iftode

Reputation: 15683

ASP .Net also sets(adds) the title of the page, even there is no value. Try to use Page.Title to dynamically set the title.

Upvotes: 1

Related Questions