I am a beginner here. I am working on this ASP.NET Core MVC
project where I am trying to load Update.cshtml
in <div id="divInventoryPageLoad"></div>
in Index.cshtml
as a PartialView
. However, I am not getting any output in the <div id="divInventoryPageLoad"></div>
in Index.cshtml
when I run the code. On checking Inspect Element
from the browser, I see that I am getting the error: POST http://localhost:52880/Inventory/Update 500 (Internal Server Error)
Index.cshtml
<div class="pm-body clearfix">
<div role="tabpanel">
<ul class="tab-nav" role="tablist">
<li class="active" role="presentation">
<a href="#inventoryDetails" aria-controls="inventoryDetails" role="tab" data-toggle="tab" aria-expanded="true" onclick="LoadInventoryUpdateDetails(@ViewBag.InventoryId)">Inventory Details</a>
</li>
<li id="inventorylocatetab">
<a href="#inventoryLocate" aria-controls="inventoryLocate" role="tab" data-toggle="tab" aria-expanded="true" onclick="LoadInventoryLocate()">Inventory Locate</a>
</li>
</ul>
</div>
<div id="divInventoryPageLoad"></div>
</div>
@section Scripts{
<script type="text/javascript">
$(document).ready(function () {
$('#divInventoryPageLoad').load('/Inventory/Update', { Id:@ViewBag.InventoryId }, function() {
});
})
function LoadInventoryUpdateDetails(Id) {
$('#divPageLoad').load('/Inventory/Update', { Id:Id }, function() {
});
}
function Locate() {
$('#divPageLoad').load('/Inventory/Locate');
}
</script>
}
Controller
// GET: /Inventory/
public IActionResult Index(int Id)
{
ViewBag.InventoryId = Id;
return View();
}
// GET : ~/Inventory/Update/Id
public IActionResult Update(int Id)
{
...
}
The ActionMethod for Update
is not getting hit when I test with the help of breakpoints
. What to do?