Dynamic PageTitle in ASP.NET


Posted in , ,

Recently I came across an issue while developing ASP.NET web application. I want the .aspx page titles to change whenever I browse a certain page on my website. After some research I was able to do this by setting the 'title' as a server control by adding runat="server" inside the tag and utilize the following in your code-behind file:

Protected pageTitle As System.Web.UI.HtmlControls.HtmlGenericControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

pageTitle.InnerText = "Title"

End Sub

If you are using a Masterpage:

use instead Page.Header.Title



Comments (0)