There is a Form which consists of Textbox which are activated or deactivated by a CheckBox ....
How can I capture the value that the user enters validating that the Check is marked?
My View:
<script type="text/javascript">
$(function (){
$("#idcheckproveedor").change(function(){
var st = this.checked;
if (st) {
$("#txtSearch").prop("disabled", false);
}
else {
$("#txtSearch").prop("disabled", true);
}
});
});
</script>
<div class="form-group">
<label>Proveedor</label>
<input type="checkbox" id="idcheckproveedor" checked="checked" />
@Html.TextBox("searchTerm", null, new { @class = "form-control", id = "txtSearch" })
</div>
My Controller:
[HttpPost]
public ActionResult BuscarRecepcion(string searchTerm, int? page, string fi, string ff, int NumeroFactura)
{
if (string.IsNullOrEmpty(searchTerm))
{
var abrir = db.Entradas.ToList();
ViewBag.Error = "Debe Ingresar un Proveedor";
return View(abrir.ToList().ToPagedList(page ?? 1, 60));
}
//CONSULTO ID PROVEEDOR
var buscarproveedor = db.Proveedors.Where(n => n.v_Nombre == searchTerm).Select(c => c.Kn_CodigoProveedor).FirstOrDefault();
var nombreproveedor = db.Proveedors.Where(n => n.Kn_CodigoProveedor == buscarproveedor).Select(b => b.v_Nombre).FirstOrDefault();
if (nombreproveedor == null)
{
ViewBag.Error = "Debe Seleccionar un Producto o Material Válido";
return View();
}
return View(nombreproveedor.ToList().ToPagedList(page ?? 1, 60));
}
Aucun commentaire:
Enregistrer un commentaire