Contents tagged with asp.net custom control
-
Creating a custom Bread Crumb control in asp.net
Hi,
We all might be aware of the bread crumbs shown on so many websites. Bread crumbs help users in a big way to navigate the website in a structured manner. Asp.net provides a very good sitemap control which can be used to display a bread crumb. This uses a sitemap file which is actually a xml file indicating the struture and hierarchy of your web site.
A few days ago a colleage of mine ran into soem issues with the standard asp.net sitemap control. It became evident that managing and keeping track of query string was not easy in the standard sitemap control.
This motivated me to develop a custom bread crumb control. The control i developed was a pretty simple one. I will discuss about this control and explain in detail about the code.
Some of the features of this bread crumb control are -
1. It keeps track of the query string of previous pages browsed.
2. It doesnt require any xml file.
This is a very simple control and as you can see it can be developed further. The asp.net sitemap control is superior to it in a lot of ways and i will recommend users to use it unless you need new features.
The breadcrumb consists of two main classes. - BreadCrumbNode and BreadCrumb
BreadCrumbNode represents a visited URL or the current page, in addition it contains information like the caption/title to be shown on the breadcrumb. You can modify the class to include more information.
The other class is the BreadCrumb which represents the BreadCrumb Control. Below is the code for both the classes -
namespace Web.Custom.Controls
{