Referencing the Control

1. Download and extract the ProudMonkey.WebTools.dll
2. Add the ProudMonkey.WebTools.dll in your project solution
3. Right click on the project and select Add Reference
4. Click on the Browse tab and locate the ProudMonkey.WebTools.dll
5. Click OK

In your master page in which your site menu is located, register the control by adding the following line below at the top most part of your page (ASPX).

 

<%@ Register Assembly="ProudMonkey.WebTools"
                     Namespace="ProudMonkey.WebTools"
                     TagPrefix="cc1" %>

 

And then declare the SiteNavigationTrail control like this:

 

<cc1:SiteNavigationTrail ID="SiteNavigationTrail1" runat="server" />

After that you can now use the SiteNavigationTrail control and start start adding trail to your individual page. Since this controls doesn't use an XML based datasource then you will have to set the trail manually to your page.

Using the Control

The SiteNavigationTrail control has AddTrail() method which accepts the following parameters: 

  1. breadCrumbContainer - the naming container to which the SiteNavigationTrail control is located. Normally this would be your master page.
  2. breadCrumbControlID - the ID of the SiteNavigationTrail control
  3. groupName - the node group name. Normally this would be the root menu item name
  4. nodeName - the menu item name to appear in the trail
  5. Level - the type of level of the trail

There are 5 main types of Level of the trail and these are:

  • Root - use this type if you want to add trail for your main menu items
  • One - use this type to add trail for 1st level sub menu items
  • Two - use this type to add trail for 2nd level sub menu items
  • Three - use this type to add trail for 3rd level sub menu items
  • NoLevel - use this type if the page is not included in your site menu items. Normally this is a page accessed via your code.

Here are some examples:

Note: Don't forget to register the namespace below in your page code behind class:

using ProudMonkey.WebTools;

Ok let's start. Considering that you have this menu below:

If you want to add trail for your main menu items then you use this code at Page_Load event:

 

 Trail.AddTrail(this.Master, "SiteNavigationTrail1","Home", "Home", Trail.Level.Root);

 

The output would look something like this:

To add trail for 1st level menu items then you can use this code:

 

 Trail.AddTrail(this.Master, "SiteNavigationTrail1", "Demo", "GridView", Trail.Level.One);

 

The output would look something like this:

To add trail for 2nd level menu items then you can use this code:

 

Trail.AddTrail(this.Master, "SiteNavigationTrail1", "Demo", "Sample C", Trail.Level.Two);

 

The output would look something like this:

To add trail for 3rd level menu items then you can use this code:

 

Trail.AddTrail(this.Master, "SiteNavigationTrail1", "Demo", "Sample C2", Trail.Level.Three);

The output would look something like this:

 

That's it! I hope someone find this control useful. Please let me know if you find any bugs. Please don't forget to leave your comments and suggestions.

Last edited Feb 7, 2013 at 5:02 PM by ProudMonkey, version 5

Comments

No comments yet.