Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

How to change ASP.net Page title Dynamically ?

Total Hit ( 6139)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


You can use HtmlGenericControl() in ASP.Net pages to change the page title dynamically. All you have to do is, set an ID for the Html TITLE tag and make it "runat=server". Once you make it runat=server, you can access the control from the server side code and set any value for it.
First lest create our test aspx page

Test1.aspx

Click here to copy the following block
<HTML>
 <HEAD>  
  <TITLE ID=pageTitle RUNAT=server> </TITLE>
 </HEAD>
<BODY>
  This is my sample ASP.net Page .. check the title
</BODY>
</HTML>

Now you have to declare a variable of type HtmlGenericControl
and set the .InnerText property of that variable in you code behind file. This is all you have to dynamically set the page title (browser title) in your ASP.Net page.

Test1.aspx.vb

Click here to copy the following block
Public Class Test1
 Inherits System.Web.UI.Page

 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 = "Page Title - " & Now()
  
 End Sub
End Class


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.