I want to display a PartialView inside a View with a shared layout, the thing is that I want to render this partial from a select value.
So, I want to know how to trigger the view from Controller depending of the selected value in the select element.
Here's the code:
EDIT
Administrador.cshtml
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Seleccione Cartera:</td>
<td>
<select id="SeleccionCartera" name="SeleccionCartera">
<option value="">Seleccione Cartera</option>
<option value="0">Activa</option>
<option value="1">Conservadora</option>
<option value="2">Moderada</option>
<option value="3">Nueva</option>
</select>
</td>
<td>
<button name="btnBuscarRegistros" class="btnExportar">Buscar</button>
</td>
</tr>
</table>
<div id="prueba" name="prueba">
//Here is where my partial displays info.
</div>
Functions.js
$("#SeleccionCartera").change(function () {
var val = $("#SeleccionCartera").val();
$("#prueba").load('Admin/SeleccionCartera/?value =' + val);
});
AdminController.cs
public ActionResult SeleccionCartera(int id)
{
string partial = "";
if(id==3)
{
partial = "_NuevaCartera";
}
return PartialView(partial);
}
If the user select "Nueva", I want to display a PartialView, if the user choose "Activa" I want to display another PartialView (or the same) from Controller.
Thanks for the help!
PD: Sorry for my English, I'm Chilean.