Naughty Ninja Naughty Ninja - 14 days ago 5
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>
</li>

<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.
</div>

Answer

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 })}
Comments