HI cdkisa:
This is a good question! It's different way to generate structure between ASP.NET and MVC.
In ASP.NET you can use DJ library to create an ContextMenuControl the code maybe like this:
1:
2:
3: [JQuery(Name = "your javascript plugin name",
4: Assembly = "jQuery",
5: DisposeMethod = "destroy",
6: ScriptResources = new string[] { "Your context menu file reference here"},
7: StartEvent = ClientRegisterEvents.DocumentReady)]
8: public ContextMenuControl:Control
9: {
10: public List
11:
12: protected override void OnPreRender(EventArgs e)
13: {
14: var builder = new JQueryScriptBuilder(this);
15: //This code only can generate top level menu items.
16: foreach(var item in MenuItems)
17: builder.AddFunctionOption(item.Text,item.OnClick,new string[]{"menuitem","menu"});
18:
19: ClientScriptManager.RegisterJQueryControl(this, builder);
20: }
21: }
22:
23: public class MenuItem
24: {
25: public string Text{get;set;}
26: public string OnClick{get;set;}
27: }
The other way write an extension in MVC ,in DJME we have an extension called "Menu" this extension also could generate context menu scripts,the following code is how we use the Menu extension
1:
2: <%:
3: Ajax.Menu(IDPrefix+"_MetaMenu")
4: .Options(options=>{
5: options.MenuType = MenuStyles.Vertical;
6: options.TopMenuCssClass = "ui-sitetools-menu";
7: options.TopItemCssClass = "ui-sitetools-menuitem";
8: options.TopItemHoverCssClass = "ui-sitetools-menuitem-hover";
9: })
10: .Items(items => {
11: items.AddMenuItem("Menu item1","/about.html")
12: .ImageUrl = Url.Content("~/Content/Images/add.png");
13:
14: var item2= items.AddMenuItem("Menu item2", Url.Action("Create"))
15: .ImageUrl = Url.Content("~/Content/Images/add_page.png");
16: //sub items.
17: item2.Items(subitems=>{
18: subitems.AddMenuItem(subitem=>{
19: subitem.Title="Client click";
20: subitem.OnClientClick="alert('Hello')";
21: });
22: });
23: })
24: .Render()
25: %>
You can get the DNA project and look inside the MenuExtensions class and lean about how i generate the menu.