Close Search Box
Search Box

Search: From:

Close
Newsletter

9Tutorials to your Inbox



ASP.NET Breadcrumbs with C#

ASP.NET Breadcrumbs with C#
Tags: ,
4,284 views
1 Star2 Star3Star4 Star5 Star (5 votes, average: 4.8 out of 5)

By utilizing breadcrumb navigation you allow your viewers to easily trace their path taken to the current location and back track if necessary.

A breadcrumb navigation usually looks something like:

Main Page > Page Design : ASP.NET Breadcrumbs with C#

Within this article you will learn how to create breadcrumb navigation using ASP.NET and C#.

In the above example we see that the viewer started on the ’Main Page’, then moved to the ‘Page Design’ section, then selected the ‘ASP.NET Breadcrumbs with C#’ page, where they currently reside. The Main Page and Page Design will be hyperlink so that you can go directly to the above sections.

The first part, ‘Main Page’ is where the user is starting; typically something like ‘Home’ or ‘Home Page’ will be used. However, we will use a variable in our code so that the user may decide what text they would like to use. The next part ‘Page Design’ is a sub-category that holds the page that the user is currently viewing, ‘ASP.NET Breadcrumbs with C#’. We know that this is the final resting spot because the ‘:’ preceding the page name indicates so. Finally, the ‘>’ is used as a separator for categories, this also is a variable, allowing for a choice of symbol.

The HTML writer to write out to

We are going to use an ASP.NET User control (.ascx) so that we may simply add this control to our pages making it easy to maintain and modify later if we should choose to. For example, if we have 100 pages and we want to modify the separator in our breadcrumb navigation from the “>” symbol to an image we will only have to modify 1 page, our .ascx page and not all 100 .aspx pages.

Creating Our Web Pages (.aspx). For each page (.aspx) you create for your website use a literal . This allows us to define the actual title for our page in the code behind. By defining the title of the page in the code behind we gain the benefit of only having to assign it once and have it not only be used for the title of our page, but also be used in our breadcrumb navigation.

Your code behind would look like this:

We created a class for our breadcrumb navigation and used that class for an ASP.NET User control (.aspx). This allows us to simply drop the User control into each web page (.aspx) we create. Once we have our User control in our page we assign the PageTitle in the code behind and this gets used for the site.

Copyright @ Abhishek Arya 2007

del.icio.us:ASP.NET Breadcrumbs with C# digg:ASP.NET Breadcrumbs with C# spurl:ASP.NET Breadcrumbs with C# newsvine:ASP.NET Breadcrumbs with C# blinklist:ASP.NET Breadcrumbs with C# furl:ASP.NET Breadcrumbs with C# reddit:ASP.NET Breadcrumbs with C# blogmarks:ASP.NET Breadcrumbs with C# Y!:ASP.NET Breadcrumbs with C# magnolia:ASP.NET Breadcrumbs with C# segnalo:ASP.NET Breadcrumbs with C#

Friends' Sites

Sponsors

Login





Featured Links

Post a Comment »








Safari hates me

Comment Guidelines

  • Hyperlinks are automatically generated.
  • <em>italic</em>
  • <strong>bold</strong>
  1. Apple Blog » Blog Archive » ASP.NET Breadcrumbs with C# November 11, 2007

    [...] By utilizing breadcrumb navigation you allow your viewers to easily trace their path taken to the current location and back track if necessary. (more…) [...]

  2. sharma December 23, 2007

    send me some projects on .net