Calling a view from another view in MVC .Net

asp.net asp.net-mvc asp.net-mvc-4 entity-framework

Question

I have a view called LoggedIn.cshtml getting called from LoggedInController. Inside the LoggedInView I have a PartialView called _LoggedInPartial to display the nav bar containing different menus like Home, Profile, etc.

I want to call another view LoggedInHomeView onClick of the home menu of the nav bar which is present inside LoggedInView.

How can I achieve that?

1
2
9/2/2016 8:23:46 AM

Popular Answer

Say you have view called LoggedIn.cshtml, in your view you render partial view called _LoggedInPartial like:

{ Html.RenderPartial("_LoggedInPartial"); }

Generally, if _LoggedInPartial is used for navigation inside this view, links are rendered like:

<ul>
    <li>
        @Html.ActionLink("Title", "ActionName", "ControllerName")
    </li>
    <li>
        @Html.ActionLink("AnotherTitle", "AnotherActionName", "AnotherControllerName")
    </li>
</ul>

Now, when you click on links you should be redirected to desired action, and it will render view for you.

2
9/2/2016 8:17:26 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow