Home page creating a second title tag

I have a simple page inside the main page (well, in the master).

In the top wizard, I have a head tag with runat="server" , with several bits, such as scripts, style sheets, etc., as well as the owner of the content. There is no title tag here.

On a page using this wizard, the content for the placeholder contains the <title>pagename</title> bit in it. I really need to install it there.

Unfortunately, when the page renders, I get my title, which is good, but also gets a second empty title tag - I assume that it is reset there by .NET.

Is there any way to stop this second header tag?

+6
master-pages title
source share
3 answers

From memory, as a result of placing runat = "server" in <head> .Net automatically adds <title> if it is not already.

I think (did not check it) if on your main page you do

 <head runat="server"> Blah <title runat="server" visible="false"></title> </head> 

setting the Title tag explicitly at the beginning of the main page and setting the visibility to false works. I think.

+16
source share

You do not need to manually insert a <title> in the head.
Just set Page.Title = "title" by code or <%@ Page Title="My Title" .. %> by markup. ASP.NET will figure out the rest and put the correct header.

+4
source share

I think using:

If you want to set the page level heading

 <%@ Master ... %> <html> <head runat="server"> <title> <asp:ContentPlaceHolder ID="titleContent" runat="server" /> </title> </head> 

Or

If you want to set a dynamic header at the home page level.

 <%@ Master ... %> <html> <head runat="server"> <title> <asp:Literal ID="litPageTitle" runat="server"></asp:Literal> </title> </head> 

is the best way to ensure that an empty title tag has not been created.

+1
source share

All Articles