Today i need to show menu on click of ASP.NET Menu…when i click any menuitem it should show a Dialog window and code for it[javascript:showmodal...] is coming from database…
how can i do that????googled it…then also no luck….then finally..explored MenuItem class from MSDN and got it…so here it is…
I had <asp:Menu> which looks like:
<asp:Menu ID=”ContextMenu” runat=”server” Orientation=”Vertical”
StaticSubMenuIndent=”10px” DynamicHorizontalOffset=”2″ Width=”150px” DynamicVerticalOffset=”2″ StaticEnableDefaultPopOutImage=”False”
ForeColor=”White” Font-Bold=”True” CssClass=”MyMenu”>
<StaticMenuItemStyle HorizontalPadding=”5px” VerticalPadding=”2px” />
<DynamicHoverStyle CssClass=”DynamicHoverStyle” ForeColor=”White” />
<DynamicMenuStyle CssClass=”DynamicHoverStyle”/>
<StaticSelectedStyle CssClass=”DynamicHoverStyle”/>
<DynamicSelectedStyle CssClass=”DynamicHoverStyle” />
<DynamicMenuItemStyle HorizontalPadding=”5px” VerticalPadding=”2px” />
<StaticHoverStyle CssClass=”DynamicHoverStyle” ForeColor=”White” />
</asp:Menu>
and Page_Load i am binding it with my data which is coming by one function and that function calls database…
ContextMenu[] contextmenu = MenuHelper.GetContextMenu(1);
MenuItem _menuitem = null;
foreach (ContextMenu item in contextmenu)
{
_menuitem = new MenuItem(item.menuTextField,item.urlField,string.Empty,item.urlField);
ContextMenu.Items.Add(_menuitem);
}
That’s it..
on click of my menu it opend ModalWindow..using ShowModalDialog.
Reference:: Pls alloccate some time and read this:
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.items.aspx