Controls You Can Use on Web Forms ASP.NET Navigation Controls Menu Control
For sites that frequently add or change content, the site’s navigational structure can be better organized and maintained in a separate XML file.
When bound to a Menu control, any change made to the XML file automatically appears in the Menu control. This ensures that updated content is always readily accessible to users of the Web site.
The Menu control can be bound to the appropriate data source type, using any of the following ways:
- The Menu control can use any hierarchical data source control, such as an XmlDataSource control or a SiteMapDataSource control.
To bind to a hierarchical data source control, set the DataSourceID property of the Menu control to the ID value of the data source control. The Menu control automatically binds to the specified data source control. This is the preferred method to bind to data.
- The Menu control can also be bound to an XmlDocument object.
To bind to this data source, set the DataSource property of the Menu control to the data source and then call the DataBind method.
The following example demonstrates how to use declarative syntax to create a Menu control bound to a SiteMapDataSource.
<asp:menu id="myMenu" runat="server"
datasourceid="siteMap"
font-size=9pt
staticdisplaylevels=2>
<dynamicmenustyle
backcolor="ghostwhite"
horizontalpadding=10
verticalpadding=5
borderstyle="outset"
borderwidth=1 />
<dynamicmenuitemstyle
itemspacing=1.5 />
<dynamichoverstyle backcolor="khaki" />
</asp:menu>
<asp:sitemapdatasource id="siteMap" runat="server" />
Show me
Customizing the Menu Control User Interface Responding to Menu Item Events