ASP.NET Syntax ASP.NET Syntax for Web Controls
Displays a menu in a Web Forms page.
Declarative Syntax
<asp:Menu
AccessKey = "string"
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid | Double | Groove |
Ridge | Inset | Outset"
BorderWidth = size
CssClass = "string"
DataSource = "string"
DataSourceID = "string"
DisappearAfter = integer
DynamicBottomSeparatorImageUrl = "uri"
DynamicEnableDefaultPopOutImage = "True | False"
DynamicHorizontalOffset = integer
DynamicItemFormatString = "string"
DynamicPopOutImageTextFormatString = "string"
DynamicPopOutImageUrl = "uri"
DynamicTopSeparatorImageUrl = "uri"
DynamicVerticalOffset = integer
Enabled = "True | False"
EnableTheming = "True | False"
EnableViewState = "True | False"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small | X-Small | Small |
Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
ID = "string"
ItemWrap = "True | False"
MaximumDynamicDisplayLevels = integer
OnDataBinding = "DataBinding event handler"
OnDataBound = "DataBound event handler"
OnDisposed = "Disposed event handler"
OnInit = "Init event handler"
OnLoad = "Load event handler"
OnMenuItemClick = "MenuItemClick event handler"
OnMenuItemDataBound = "MenuItemDataBound event handler"
OnPreRender = "PreRender event handler"
OnUnload = "Unload event handler"
Orientation = "Horizontal | Vertical"
PathSeparator = "string"
runat = "server"
ScrollDownImageUrl = "uri"
ScrollDownText = "string"
ScrollUpImageUrl = "uri"
ScrollUpText = "string"
SkinID = "string"
SkipLinkText = "string"
StaticBottomSeparatorImageUrl = "uri"
StaticDisplayLevels = integer
StaticEnableDefaultPopOutImage = "True | False"
StaticItemFormatString = "string"
StaticPopOutImageTextFormatString = "string"
StaticPopOutImageUrl = "uri"
StaticSubMenuIndent = size
StaticTopSeparatorImageUrl = "uri"
Style = "string"
TabIndex = integer
Target = "string"
ToolTip = "string"
Visible = "True | False"
Width = size
>
<DataBindings>
<asp:MenuItemBinding
DataMember = "string"
Depth = integer
Enabled = "True | False"
EnabledField = "string"
FormatString = "string"
ImageUrl = "uri"
ImageUrlField = "string"
NavigateUrl = "uri"
NavigateUrlField = "string"
PopOutImageUrl = "uri"
PopOutImageUrlField = "string"
Selectable = "True | False"
SelectableField = "string"
SeparatorImageUrl = "uri"
SeparatorImageUrlField = "string"
Target = "string"
TargetField = "string"
Text = "string"
TextField = "string"
ToolTip = "string"
ToolTipField = "string"
Value = "string"
ValueField = "string"
/>
</DataBindings>
<DynamicHoverStyle />
<DynamicItemTemplate>
<!-- child controls -->
</DynamicItemTemplate>
<DynamicMenuItemStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid | Double |
Groove | Ridge | Inset | Outset"
BorderWidth = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small | X-Small | Small |
Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
ItemSpacing = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
<DynamicMenuStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid | Double |
Groove | Ridge | Inset | Outset"
BorderWidth = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small | X-Small | Small |
Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
<DynamicSelectedStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid | Double |
Groove | Ridge | Inset | Outset"
BorderWidth = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small | X-Small | Small |
Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
ItemSpacing = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
<Items />
<LevelMenuItemStyles>
<asp:MenuItemStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid |
Double | Groove | Ridge | Inset | Outset"
BorderWidth = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small |
X-Small | Small | Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
ItemSpacing = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
</LevelMenuItemStyles>
<LevelSelectedStyles>
<asp:MenuItemStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid |
Double | Groove | Ridge | Inset | Outset"
BorderWidth = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small |
X-Small | Small | Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
ItemSpacing = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
</LevelSelectedStyles>
<LevelSubMenuStyles>
<asp:SubMenuStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid |
Double | Groove | Ridge | Inset | Outset"
BorderWidth = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small |
X-Small | Small | Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
</LevelSubMenuStyles>
<StaticHoverStyle />
<StaticItemTemplate>
<!-- child controls -->
</StaticItemTemplate>
<StaticMenuItemStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid | Double |
Groove | Ridge | Inset | Outset"
BorderWidth = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small |
X-Small | Small | Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
ItemSpacing = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
<StaticMenuStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid | Double |
Groove | Ridge | Inset | Outset"
BorderWidth = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small | X-Small | Small |
Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
<StaticSelectedStyle
BackColor = "color name | #dddddd"
BorderColor = "color name | #dddddd"
BorderStyle = "NotSet | None | Dotted | Dashed | Solid | Double |
Groove | Ridge | Inset | Outset"
BorderWidth = size
CssClass = "string"
Font-Bold = "True | False"
Font-Italic = "True | False"
Font-Names = "string"
Font-Overline = "True | False"
Font-Size = "string | Smaller | Larger | XX-Small | X-Small | Small |
Medium | Large | X-Large | XX-Large"
Font-Strikeout = "True | False"
Font-Underline = "True | False"
ForeColor = "color name | #dddddd"
Height = size
HorizontalPadding = size
ItemSpacing = size
OnDisposed = "Disposed event handler"
VerticalPadding = size
Width = size
/>
</asp:Menu>
For information on the individual members of this class, see Menu in the class library.
The Menu control renders a menu in a Web Forms page and is often used in combination with a SiteMapDataSource control for navigating a Web site.
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
Menu Class Menu Web Server Control