Naughty Ninja Naughty Ninja - 1 year ago 66
C# Question

Call an action under the JQuery tab

Got couple of tabs and partial views rendering under those.

What I'd like to do is instead of just rendering the partial view but to call an action that is gonna return the view.

Something like:

<li class="active">
<a data-modal-transform="lg" data-toggle="tab" href="#webcms-shop-home">@Lang("Home")</a>

<div class="tab-pane fade in active" id="webcms-shop-home" style="position: relative;">

@*@Html.Partial("~/Views/WebCMS/Shop/_ShopCms.cshtml", Model)*@ //Instead of this !

@Url.Action("Shop", "WebCms", new { id = Model.ShopId }) //This is rendering as /WebCms/Shop/12 atm.

Answer Source

You need to use Html.RenderAction instead of Url.Action

Invokes a child action method and renders the result inline in the parent view.

@{Html.RenderAction("Shop", "WebCms", new { id = Model.ShopId })}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download