Actually, I have two questions to ask you related to the partialview.
First, I will comment on how I show the partialview
Question One
Add.cshtml
@Html.EditorFor(x => x.Suma)
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
@{ Html.RenderPartial("PartialGrupoConexion", Model.conexionadoviewmodel); }
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
That is the method by which I open a modal with a partialview inside, the first question is as follows.
Is this the best method of using a partialview? (within a clear modal is)
Or would it be better to use jQuery and Ajax to insert the partialview data into the modal?
Question Two
My second problem with the partialview, is that I do not understand what would be the method to obtain information from a normal view, I will use an example of my problem trying to be interpreted in the simplest way.
In the main view ( Add.cshtml ) I have an EditorFor that uses the Sum field of the Model.
And having a partialview similar to this
@Html.EditorFor(x => x.PrimerElemento)
@Html.EditorFor(x => x.SegundoElemento)
<button type="button">Calcular</button>
I managed to return the sum of these two fields to the main view, I had some ideas to do it with JQuery, but apparently I should not use it within a PartialView
EDIT The viewmodel would be something like that
public class Principal
{
public int suma { get; set; }
public int resta { get; set; }
public SumaPartialView SumaParcial{ get; set; }
}
public class SumaPartialView
{
public int valor1 { get; set; }
public int valor2 { get; set; }
public int suma { get; set; }
}
I hope I expressed myself well, thank you very much for the good vibes!