loads of useful information, examples and tutorials pertaining to web development utilizing asp.net, c#, vb, css, xhtml, javascript, sql, xml, ajax and everything else...

 



Advertise Here
C-Sharpener.com - Programming is Easy!  Learn Asp.Net & C# in just days, Guaranteed!

Make sure you have consistent page titles on your web site

by naspinski 1/23/2009 2:14:00 PM

A simple way to catch inconsistency in your titles

Page Titles are often overlookd aspects of web design and can be a simple way to add a little value and professionalism to your site. Users can use your page title to quickly scan bookmarks or on tabs in their browser. Therefore, I feel it is good practice to have a consistent page title naming scheme across your site.

Often I seem to screw up making titles for my pages or forget to add one altogether, or even worse, have the dreaded 'Untitled Page' that was ever=resent before VS2008 SP1. I use MasterPages so there is a centralized structure to build on, and I used this to come up with a way to provide a consistent page title:
string TITLE_ROOT = "My Site";
protected void Page_Load(object sender, EventArgs e)
{
  this.Page.Title = (string.IsNullOrEmpty(this.Page.Title) || this.Page.Title.Equals("Untitled Page"))
    ? TITLE_ROOT : TITLE_ROOT + " :: " + this.Page.Title;


This way, any page that uses this MasterPage will have a nicely formatted title. If you forgot to set a title it would simply be:
My Site

But, say you titled the page "Welcome New Users!", it would then look like this:
My Site :: Welcome New Users!

An easy way to catch myself from making mistakes as well as making it much more consistent.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

asp.net | c#

Related posts


Comments are closed