0

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Vijjendra
  • 24,223
  • 12
  • 60
  • 92

1 Answers1

1

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.

Adrian Iftode
  • 15,465
  • 4
  • 48
  • 73
  • I have tried this but it add the tag just before the closing head tag. but I want just below the opening head tag. – Vijjendra Mar 20 '12 at 10:35
  • This behavior is odd, are sure about this? – Adrian Iftode Mar 20 '12 at 10:38
  • yes, I got the Solutions for that. Just add the default test on master page any position where you want to place, just reset that on page where you want to set dynamically. – Vijjendra Mar 20 '12 at 11:08