ASP.NET / C#

Dynamic Page Titles in ASP.NET

How to code DYNAMIC PAGE TITLES in your asp.net page:

This method allows for control of the SEO suggested Page Titles to be controlled inside of Visual Studio.
In the Master Pages leave this blank:    (located inside the of the html code)
In the Content Pages leave this blank:  Page Title=””  (located on the top line where you register the page)
In the code-behind of the page , type code like this:

// Set Page Title based on the CMS id#:

try
{
  pid = Convert.ToInt32(Request.QueryString["pid"]);
  Session.Contents["pid"] = pid;

     switch (pid)
     {
     case 14: 
        this.Page.Header.Title = "Residential Garage Doors : Banner Series" 
     break;

     case 18: 
         this.Page.Header.Title = "Residential Garage Doors : Thermacore";
     break;
     }

}
catch {
if (pid == 0)
   {
     Page_Error("ContentID Missing");
   }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s