Click here to Skip to main content
15,743,429 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to add a partialview(With some databse's datas) for common view to all page.
I did that, when partialview render from other view then not invoke controller PartialViewResult but invoke if direct render from url(localhost/Home/partialviewName).
code is bellow
This is controller
public PartialViewResult partial(Auction auc)
            auc.Name = "Abhilash Kumar";
            return PartialView("~/Views/Home/partial.cshtml",auc);

This is partial View
@model MyMVC.Models.Auction
<div style="padding:10px 10px 10px 10px">
    <p style="color:#ff0000">@Model.Name </p>

So how to invoke controller when partial view render from any other view.

1 solution

If you want to call a action result which return a partial view you can use Html.RenderAction()

Go through the below link.

MVC Render Partial view with action from controller[^]
Share this answer
Abhilask kumar 13-Jan-16 3:49am    
when use Html.RenderAction() then error occur "Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'"
suhel_khan 13-Jan-16 4:35am    
are you passing action and controller in renderaction
suhel_khan 13-Jan-16 4:47am    
somthing like this Html.RenderAction("Category","Home")
Abhilask kumar 13-Jan-16 5:06am    
@{Html.RenderAction("master", "Home"); }
checked but same error.
F-ES Sitecore 13-Jan-16 7:12am    
That is rendering the "master" action on the "Home" controller, but your action is called "partial".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900