We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Render Partial view in menu

Thread ID:

Created:

Updated:

Platform:

Replies:

132631 Sep 13,2017 06:30 AM UTC Sep 15,2017 05:22 AM UTC ASP.NET MVC 3
loading
Tags: Menu
Muhammad Tassadaque Zia
Asked On September 13, 2017 06:30 AM UTC

Hi
In my menu I have the following code

menu.Add()
        .Text("Reports")
         .Children(child => {
             child.Add().ContentTemplate(Html.RenderAction("documentcontent"));
         });
        }


As you see I want to renderaction in contentTemplate but it gives me following error
 cannot convert from 'void' to 'System.Action<Syncfusion.JavaScript.Models.MenuBaseItem>'

My objective is to render partial view inside top menu reports ==> partial view

Please let me know the syntax for rendering partial view in menu


Prince Oliver [Syncfusion]
Replied On September 14, 2017 06:38 AM UTC

Hi Muhammad, 

Thank you for contacting Syncfusion forums. 

To render Partial view in menu control, you can use Html.Partial instead of Html.RenderAction. Kindly refer to the following code snippet. 

<div class="imgframe"> 
    @Html.EJ().Menu("syncfusionProducts").Items(menu => 
        { 
            menu.Add().Text("Books").Children(child => 
                    { 
                        child.Add().ContentTemplate(@<div> 
                                 @(Html.Partial("Documentcontent")); 
                        </div>); 
                    }); 
        }).Width("612") 
</div> 

We have prepared a sample for your reference. Please find the sample from the following location: http://www.syncfusion.com/downloads/support/forum/132631/ze/MenuPartialView1384427629 

Regards, 
Prince 


Muhammad Tassadaque Zia
Replied On September 14, 2017 09:25 AM UTC

Thanks for your reply

Your solution is working for HTML.Partial but it is not working for

Html.Action or Html.RenderAction

If you could provide the working solution for the above helpers


Prince Oliver [Syncfusion]
Replied On September 15, 2017 05:22 AM UTC

Hi Muhammad, 

Thank you for your update. 

To render Partial view in menu control with Html.RenderAction, you need to use create event and append the rendered content into the menu’s <li> element. Kindly refer to the following code snippet. 

<h3>Html.RenderAction</h3> 
<div class="imgframe"> 
    @Html.EJ().Menu("syncfusionProducts").Items(menu => 
        { 
            menu.Add().Text("Books").Children(child => 
                    { 
                        child.Add().ContentTemplate(@<div> 
                                    @{Html.RenderAction("Documentcontent");} 
                        </div>); 
                    }); 
        }).Width("612").ClientSideEvents(e=>e.Create("oncreate")) 
</div> 
<script> 
    function oncreate(args) { 
        $(this.element.find("ul li div")[0]).append($("div.temp.temp1")); 
    } 
</script> 

To render Partial view in menu control with Html.Action, kindly refer to the following code snippet. 

<h3>Html.Action</h3> 
<div class="imgframe"> 
    @Html.EJ().Menu("syncfusionProducts2").Items(menu => 
    { 
        menu.Add().Text("Books").Children(child => 
                { 
                    child.Add().ContentTemplate(@<div> 
                            @(Html.Action("Documentcontent2")); 
                        </div>); 
                    }); 
        }).Width("612") 
</div> 

We have prepared a sample for your convenience, kindly refer to the following link for the sample: http://www.syncfusion.com/downloads/support/forum/132631/ze/MenuPartialView185856840 

Regards, 
Prince 




CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;