Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

master page generating a second title tag

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

In the top master I have the head tag with runat="server", with a number of bits such as scripts, stylesheets, etc. and also a contentplaceholder. There is no title tag here.

In the page that uses this master, the content for the placeholder contains the <title>pagename</title> bit in it. I really have to set it in there.

Unfortunately when the page is rendered I get my title which is all good, but also get a second blank title tag - I presume dumped in there by .NET.

Is there any way of stopping this second title tag coming out?

like image 231
nat Avatar asked Jan 05 '10 12:01

nat


People also ask

What does a master page contain?

What is a Master Page? A Master Page is a nonprinting page that you can use as the template for the rest of the pages in your document. Master pages can contain text and graphic elements that will appear on all pages of a publication (i.e. headers, footers, page numbers, etc.)

What is a title tag example?

It's simply the headline on the SERP (search engine results page). For example, if you Google “kitchen appliances,” you'll see that one of the top results is from IKEA. In this case, the page title tag is “Kitchen Appliances – IKEA.” This is what both people and search engines will see as the title of your page.

Which tag inside a master page is used inside which the Web user control gets loaded?

Add the Web User Control to the Contents Page then "Register Tag" and write the code to access the control by the "TagPrefix" and "TagName".

How can I add header and footer in master page in asp net?

Add a header or footer to a single-page master pageOn the View menu, click Header and Footer.


2 Answers

From memory, by virtue of putting the runat="server" on the <head> .Net automagically adds a <title> if there isn't one already.

I think (haven't tested it) is if in your masterpage you do

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

setting the Title tag explicitly in the Head of the masterpage and setting visibility to false works. I think.

like image 76
danswain Avatar answered Oct 13 '22 11:10

danswain


You don't have to manually insert <title> to 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 right title.

like image 26
Kobi Avatar answered Oct 13 '22 09:10

Kobi