Glossary Item Box
While the Navigator Control is building the menu, it raises events. This means that it will run code that you provide (called event handlers) during processing. Your code can change the appearance and content of the resulting menu. This document describes using event handlers to add static items to the menu.
Three events are raised during the processing of the menu:
| Event | Description |
|---|---|
| TopLevelCreated | Raised after the top-level items have been identified and added to the list of items that will be in the menu. The subcategories have not yet been added. |
| SubcategoriesCreated | Raised each time a group of subcategories, all at the same level, have been identified and added to the list of items that will be in the menu. |
| ItemCreated | Raised each time an item is added to the menu from the list described in the other 2 events. |
The best events to use for adding content are TopLevelCreated and SubcategoriesCreated. In both of these events, you have access to the list of items that will be displayed in the menu. You can add or delete items in your event handler. To add an event handler, you follow these 2 steps:
In this walk through, we will add an event handler to TextNavigator1.ascx that adds a link to the "Contact Us" page at ContactUs.aspx (this assumes you created this page). You can check your work by comparing it to TextNavigator5.ascx in the Controls directory of the distribution and copied to the Controls directory of your store. TextNavigator5.ascx uses a very similar technique to add 2 items to the menu.
<%@ Control Language="vb" Inherits="System.Web.UI.UserControl" %> <%@ Register
TagPrefix="sfaddons"
Namespace="StructuredSolutions.WebControls"
Assembly="SSNavigator" %> <%' © 2005 Structured Solutions %>
<script runat="server"> Sub TopLevelCreated(ByVal sender As Object, _ ByVal e As StructuredSolutions.WebControls.NavigatorItemListEventArgs) Dim item As StructuredSolutions.WebControls.NavigatorItem ' Add one item to the bottom of the list item = New StructuredSolutions.WebControls.NavigatorItem() item.DisplayName = "Contact Us" item.Link = "ContactUs.aspx" e.Items.Add(item) End Sub </script>
<sfaddons:Navigator id="Navigator1" runat="server"
OnTopLevelCreated="TopLevelCreated">
Open a store page and you will see the effect of your changes. The "Contact Us" item will always appear on the menu, regardless of whether you are using Depth="Tree" or Depth="Branch".
Copyright © 2005 by Structured Solutions. All rights reserved.
Version 1.3.2