I am new to the world of MVC programming with C #, I already read the topic, made some examples and of course with the guide of StackOverflow I think I'm doing well.
However I find myself with an exercise that I want to perform and from which I have seen several answers but none has worked for me, and I come to you asking for the support.
Index
@{
ViewBag.Title = "Bienvenido";
}
<div class="container-fluid">
<div class="row">
<div class="col-md-3" id="menu">
<ul class="nav nav-pills nav-stacked">
<li role="presentation" class="active"><a href="#">Inicio</a></li>
<li role="presentation"><a href="#">Datos Generales</a></li>
<li role="presentation"><a href="#">Datos Curriculares</a></li>
<li role="presentation"><a href="#">Experiencia Laboral</a></li>
<li role="presentation"><a href="#">Datos Laborales</a></li>
<li role="presentation"><a href="javascript:void(0)" id="dependientes">Cónyuge y Dependientes</a></li>
<li role="presentation"><a href="#">Inmuebles</a></li>
<li role="presentation"><a href="#">Vehículos</a></li>
<li role="presentation"><a href="#">Muebles</a></li>
<li role="presentation"><a href="#">Inversiones</a></li>
<li role="presentation"><a href="#">Adeudos</a></li>
<li role="presentation"><a href="#">Posible Conflicto de Intereses</a></li>
<li role="presentation"><a href="#">Observaciones</a></li>
</ul>
</div>
<div class="col-md-9">
<div class="row" id="opciones">
</div>
<div class="row" id="crear">
</div>
<div class="row" id="registros">
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#dependientes').click(function () {
$.get('@Url.Action("Create","Dependientes")', function (data) {
$('#crear').replaceWith(data);
});
});
});
$(function () {
$('#dependientes').click(function () {
$.get('@Url.Action("Mostrar","Dependientes")', function (data) {
$('#registros').replaceWith(data);
});
});
});
</script>
Partial View _Mostrar
@model List<projectD.Models.dependiente>
@{
ViewBag.Title = "_Mostrar";
}
<br />
<div class="container">
<div class="row">
@foreach (var item in Model)
{
<div class="card" style="width: 20rem; display:inline-block; margin-top:10px">
<img class="card-img-top" src="~/Content/images/familia.png" alt="Card image cap" width="50" height="50">
<div class="card-block">
<h4 class="card-title">Dependiente</h4>
<p class="card-text">
@item.nombre
<br />
@item.apellidoPaterno
<br />
@item.apellidoMaterno
<br />
@item.CURP
</p>
@Html.ActionLink("Detalle", "Details", new { id = item.idDependiente }, new {@class= "btn btn-primary"})
</div>
</div>
}
</div>
</div>
I have a project with a main view, which has a menu to the left when selecting each option to the right render two partial views each with its controller the first to add records and the second to display them. main screen
What I want to do is that when I click on add record, only the partial views are updated and the URL is not reloaded since I would lose the menu option in which I am.
I hope you can support me