This is a migrated thread and some comments may be shown as answers.

[Solved] Using Areas in Menu throws exception - MVC 3 Razor

0 Answers 42 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 13 Sep 2012, 01:46 PM
This post is essentially identical to a post from a week ago on the same subject - but no one has answered it.

Using Areas in Telerik Menu throws exception - MVC 3 Razor

The menu referencing areas works initially (i.e. when called from the "home" url - but when invoked from an Area, after successfully calling the Area controller, the view rendering throws an exception when trying to render the menu.  Note the local var tMenu is NOT null when the exception is thrown - but something in its MenuBuilder structure apparently is.

I can get more primitive @Html.ActionLink to work fine with the same areas, but these menus are far less slick/functional than the Telerik menus (i.e good sub-sub-sub menu support)

Please help

Thanks

David Laub

               @{
                    var tMenu =
                    Html.Telerik().Menu()
                        .Name("menuX") // do NOT use name "menu" or Telerik (Vista) CSS will be overruled by "ugly" standard MVC menu css rules
                        .Items(menuItem =>
                        {
                            menuItem.Add().Text("Home").Action("Index", "Home", new { area = "" });
                            menuItem.Add().Text("Admin").Action("Index", "Home", new { area = "" }).Items(submenuItem =>
                            {
                                submenuItem.Add().Text("Vendor Master Data").Action("Index", "MasterDataVendor", new { area = "Admin" });
                                submenuItem.Add().Text("User Security").Action("Index", "Home", new { area = "" }).Items(sub_submenuItem =>
                                    {
                                        sub_submenuItem.Add().Text("Role").Action("Index", "FAR_Telerik", new { area = "Staging" });
                                        sub_submenuItem.Add().Text("Role Assign").Action("Index", "FARA_Telerik", new { area = "Staging" });
                                        sub_submenuItem.Add().Text("Role M-D").Action("Index", "RoleMD", new { area = "Staging" });
                                    });
                            });
                            menuItem.Add().Text("Adjustments").Action("Index", "Home", new { area = "" }).Items(submenuItem =>
                            {
                                submenuItem.Add().Text("Freight").Action("Index", "Freight", new { area = "Adjustment" });
                                submenuItem.Add().Text("Purchase Order").Action("Index", "PurchaseOrder", new { area = "Adjustment" });
                                submenuItem.Add().Text("PO M-D").Action("Index", "POMD", new { area = "Staging" });
                                submenuItem.Add().Text("Raw Adjustment").Action("Index", "Raw", new { area = "Adjustment" });
                            });
                            menuItem.Add().Text("Queries").Action("Index", "Home", new { area = "" }).Items(submenuItem =>
                            {
                                submenuItem.Add().Text("Subledger").Action("Index", "MasterDataVendor", new { area = "Admin" });
                            });
                        });
                        //.Render();
                        try
                        {
                            var html = tMenu.ToHtmlString();   
                            tMenu.Render();                        
                        }
                        catch (Exception ex)
                        {
                            var msg = ex.Message;  // swallow exception for Time being
                        }


                    }

@*                <ul id="menu">
                    <li>@Html.ActionLink("Home", "Index", "Home", new { area = ""}, null)</li>
                    <li>@Html.ActionLink("Adjustments", "Index", "Default", new { area = "Admin" }, null)
                        <ul>
                            <li>@Html.ActionLink("Freight", "Index", "Freight", new { area = "Adjustment" }, null)</li>
                            <li>@Html.ActionLink("Purchase Order", "Index", "PurchaseOrder", new { area = "Adjustment" }, null)</li>
                            <li>@Html.ActionLink("PO M-D","Index", "POMD", new { area = "Staging" }, null)</li>
                            <li>@Html.ActionLink("Raw Adjustment", "Index", "Raw", new { area = "Adjustment" }, null)</li>
                        </ul>
                    </li>
                    <li>@Html.ActionLink("Queries", "Index", "Default", new { area = "Admin" }, null)
                        <ul>
                            <li>@Html.ActionLink("Subledger", "Index", "MasterDataVendor", new { area = "Admin" }, null)</li>
                        </ul>
                    </li>
                    <li>@Html.ActionLink("Admin", "Index", "Default", new { area = "Admin" }, null)
                        <ul>
                            <li>@Html.ActionLink("Vendor Master Data", "Index", "MasterDataVendor", new { area = "Admin" }, null)</li>
                            <li>@Html.ActionLink("User Security", "Index", "MasterDataVendor", new { area = "Admin" }, null)
                                <ul>
                                    <li>@Html.ActionLink("Role","Index", "FAR_Telerik", new { area = "Staging" } ,null)</li>
                                    <li>@Html.ActionLink("Role Assign","Index", "FARA_Telerik", new { area = "Staging" } ,null)</li>
                                    <li>@Html.ActionLink("Role M-D","Index", "RoleMD", new { area = "Staging" },null)</li>
                                </ul>
                            </li>
                        </ul>
                    </li>
                </ul>*@
Tags
Menu
Asked by
David
Top achievements
Rank 1
Share this question
or