| Site Navigation |
| |
| The Menu View Web Server Control |
| |
| In ASP.NET, using Menu control you can display static as well as dynamic menus for your ASP.NET Web pages. You can configure the contents of the Menu control directly in the control, or you can specify the contents by binding the control to a data source. |
| |
| You can control the appearance, orientation, and content of an ASP.NET Menu control without writing any code. In addition to the visual properties exposed by the control, the control supports ASP.NET control skins and themes. |
| |
| Displaying Static Behavior |
| |
| The Static Menu items always present on the web page. By using StaticDisplayLevels property of the Menu control, the static display behavior can be maintained. The StaticDisplayLevels property indicates how many levels to display statically from the root of the menu e.g. if StaticDisplayLevels is set to 2, your menu will be expanded to statically display its first two levels. The minimum static display level is 1, and the control will throw an exception if the value is set to 0 or a negative number. |
| |
| Displaying Dynamic Behavior |
| |
| The Dynamic Menu items come into view whenever a user opens a parent MenuItem or user hover the mouse over it. The MaximumDynamicDisplayLevels property specifies how many levels of dynamically appearing menu nodes should be displayed after the static display level. For example, if your menu has a static level of 2 and a dynamic level of 1, the first two levels of your menu would be statically displayed, while the next one level would be dynamic. If MaximumDynamicDisplayLevels is set to 0, no menu nodes will be dynamically displayed. If the MaximumDynamicDisplayLevels is set to a negative number, an exception is thrown. |
| |
| Manually Addition of Menu Items |
| |
| You can add individual menu items to the control by specifying them in the Items property. The Items property is a collection of MenuItem objects. The following example shows the declarative markup for a Menu control with three items, each of which has two child items: |
| |
<asp:Menu ID="MyMenu" runat="server" StaticDisplayLevels="3">
<Items>
<asp:MenuItem Text="FileMenu" Value="FileMenu">
<asp:MenuItem Text="New File" Value="New File "></asp:MenuItem>
<asp:MenuItem Text="Open File " Value="Open File "></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="Edit File " Value="Edit File ">
<asp:MenuItem Text="Copy File " Value="Copy File "></asp:MenuItem>
<asp:MenuItem Text="Paste File " Value="Paste File "></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="View File " Value="View File ">
<asp:MenuItem Text="Normal File " Value="Normal File "></asp:MenuItem>
<asp:MenuItem Text="Preview File " Value="Preview File "></asp:MenuItem>
</asp:MenuItem>
</Items>
</asp:Menu> |
| |
| Modifying appearance and Behavior |
| |
| You can change the behavior of the Menu control by using its properties. You can also control the behavior of dynamic display, including the amount of time a menu node remains visible once it is displayed. |
| |
| The various display properties to change the look of the Menu control are following: |
| |
| Orientation: The two values possible for this property are Vertical and Horizontal, Vertical is default value. You can set Orientation property of the Menu orientation from horizontal to vertical or vice versa, as given below: |
| |
Menu.Orientation = Orientation.Vertical
Menu.Orientation = Orientation.Horizontal |
| |
StaticFormatString: This property is used to bind the data in the text display for a is statically created menu.
DynamicFormatString: This property is used to bind the data in the text display for a is dynamically created menu.
StaticPopOutImageUrl: This property is used to set the pop-out symbol to an image of your choice which is statically created menu.
DynamicPopOutImageUrl: This property is used to set the pop-out symbol to an image of your choice which is dynamically created menu. |
| |
| You can customize individual properties of the Menu control to specify the size, color, font, and other characteristics of its appearance. You can also apply skins and themes to the Menu control. |
| |
|
| |