27 September 2010

Dynamically Setting the Title of a Web Page

Using the ASP.Net Literal control, you can dynamically set the title of your web page.


Declare a literal control in the <title> tag.
<head>
    <title>
<asp:Literal ID="ltrlTitle" runat="server"></asp:Literal>
    </title>
</head>


And then set the value for the literal, say in page load event.
protected void Page_Load(object sender, EventArgs e)
{
  ltrlTitle.Text = "My Dynamic Title";
}

No comments:

Post a Comment