I am trying to add a partial view inside a layout page.
Model
public class SummaryPanelModel
{
public int TotalDesignDocs { get; set; }
public int TotalVendorDocs { get; set; }
public int TotalBusinessDocs { get; set; }
public int TotalManagementDocs { get; set; }
}
SummaryPanel_Partial Partial View Controller:
public ActionResult SummaryPanel_Partial()
{
rep = new SummaryRepository();
SummaryPanelModel model = new SummaryPanelModel();
model = rep.ReadsummaryPanel();
return View(model);
}
Layout Page
<!DOCTYPE html>
<html lang="en">
@{
Layout = null;
}
@Html.Partial("SummaryPanel_Partial")
SummaryPanel_Partial Partial View:
@model Doc.Web.Models.SummaryPanel.SummaryPanelModel
<div id="pnlBar">
@Html.Label(Model.TotalDesignDocs.ToString())
<div/>
even though I passed the model in the controller action, the model always has a zero value in a partial view.
source
share