Tuesday, January 31, 2006

Create ASP.Net Page Title in Web Browser

I want to introduce you how to create page Title in your web browser. I create the title first time using Visual Studio .Net 2003.

The steps are described below:
1. Add id and runat server at your asp page.
    <title id="PageTitle" runat="server"></title>
2. Add a HtmlGenericControl object in your code-behind.
    Protected PageTitle As HtmlGenericControl
3. Set the innertext for the PageTitle object in your code-behind.
    PageTitle.InnerText = "This is a new title"

These three steps will set your web browser title to a new title.

Now I migrate my application to Microsoft .Net 2.0.
Using Microsoft .Net 2.0, the steps can be written in one line:
Page.Title = "This is a new title"

The line above is a new feature in Microsoft .Net 2.0. I create my application using Visual Studio .Net 2005. This is only one enhancement in this version.

No comments: