How create View page which is composed of three partial view pages? I am using ASP.NET MVC
//
// GET: /Partial/
public ActionResult View1()
{
var upit = from i in proba.name
select i;
return PartialView("upit",proba.name);
}
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Index</h2>
<div><%Html.RenderPartial("View1",proba.name); %></div>
</asp:Content>
Why this code return error: Object reference not set to an instance of an object.
I think you want to use RenderAction, not RenderPartial. View1 is an action, not a view. It returns the partial view,
upit. Note that this requires MVC2 (or MVC1 + futures). You also probably want to decorate the action with the ChildActionOnlyAttribute unless you intend to call it from AJAX as well.The reason you are getting the specific error is that the
probavariable isn’t defined in the view, nor does it need to be. In your case, the action determines the model being passed to the partial view so there’s no need for any data to be passed. You could only pass it via query parameters anyway when rendering an action.