Change Menu maximum dynamic display levels
Menu is an asp.net web server control. menu control's MaximumDynamicDisplayLevels property get or set the number
of menu levels to render for a dynamic menu.
this property value data type is System.Int32. this integer value represents the number of menu levels to render for a dynamic menu. the MaximumDynamicDisplayLevels property default value is 3. this property throw an exception (ArgumentOutOfRangeException) if we set the property value less than 0 (zero). if we set this property value to 0 then it will render a static menu without any dynamic menus.
the following asp.net c# example code demonstrate us how can we set or change the menu control's maximum dynamic display levels value programmatically at run time in an asp.net application.
this property value data type is System.Int32. this integer value represents the number of menu levels to render for a dynamic menu. the MaximumDynamicDisplayLevels property default value is 3. this property throw an exception (ArgumentOutOfRangeException) if we set the property value less than 0 (zero). if we set this property value to 0 then it will render a static menu without any dynamic menus.
the following asp.net c# example code demonstrate us how can we set or change the menu control's maximum dynamic display levels value programmatically at run time in an asp.net application.
MenuMaximumDynamicDisplayLevels.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
Menu1.MaximumDynamicDisplayLevels = 1;
}
protected void Button2_Click(object sender, System.EventArgs e)
{
Menu1.MaximumDynamicDisplayLevels = 0;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to set, change Menu maximum dynamic display levels programmatically</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy; font-style:italic;">Menu Example: MaximumDynamicDisplayLevels</h2>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"/>
<div style="height:150px">
<asp:Menu
ID="Menu1"
runat="server"
DataSourceID="SiteMapDataSource1"
Font-Bold="true"
ForeColor="LightSkyBlue"
>
</asp:Menu>
</div>
<asp:Button
ID="Button1"
runat="server"
ForeColor="OliveDrab"
Text="MaximumDynamicDisplayLevels 1"
Height="45"
OnClick="Button1_Click"
Font-Bold="true"
/>
<asp:Button
ID="Button2"
runat="server"
ForeColor="OliveDrab"
Text="MaximumDynamicDisplayLevels 0"
Height="45"
OnClick="Button2_Click"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>
Web.sitemap
Web.sitemap source code here.


