Tuesday, July 10, 2007

ASP.NET Tip: How to prevent the title tag from rendering

In ASP.NET, those who want complete control over the contents of the <head> section of a page get frustrated by the fact that ASP.NET automatically inserts a <title> tag.

You can even set Me.Page.Title to String.Empty, and it will still generate and render a <title> tag.

The answer is maddeningly simple:

Put a <title> tag into the <head> section as follows:

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

This turns the <title> tag into a server control, and then the visible attribute prevents the automatically-generated title from rendering to the page.

0 Comments:

Post a Comment

<< Home