Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/08/2012, 23:47
Avatar de Darsk
Darsk
 
Fecha de Ingreso: mayo-2011
Mensajes: 39
Antigüedad: 12 años, 10 meses
Puntos: 0
Habilitar y desabilitar botones

Hola querida comunidad, les cuento, teng el siguiente problema, quiero que cuando se abra mi pagina(en lenguaje c#) los botones con los que agrego a sql esten deshabiltados cuando el texto box donde ingreso el rut y el otro textbox donde ingreso el id esten vacios, por ende uando cargue la pagina ya esten innactivos, y cuando ingrese al menos un caracter se habiliten automaticamente, he intentado algunas formas pero ninguna me ha funcionado, mi idea era en la propiedad del text box de los 2 textbox en cuestion usando el evento text_changed era este, ayuda por favor.


protected void txtRut_TextChanged(object sender, EventArgs e)
{
if ((txtRut.Text != "") && (txtId.Text != ""))
{
btGuardar.Enabled = true;
btEliminar.Enabled = true;
btEditar.Enabled = true;
btMostrar.Enabled = true;
}
else
{
btGuardar.Enabled = false;
btEliminar.Enabled = false;
btEditar.Enabled = false;
btMostrar.Enabled = false;

Response.Write("<SCRIPT>alert('Debe ingresar Rut e Id');</SCRIPT>");
}
}
protected void txtId_TextChanged(object sender, EventArgs e)
{
if ((txtRut.Text!="") && (txtId.Text != ""))
{
btGuardar.Enabled = true;
btEliminar.Enabled = true;
btEditar.Enabled = true;
btMostrar.Enabled = true;
}
else
{
btGuardar.Enabled = true;
btEliminar.Enabled = true;
btEditar.Enabled = true;
btMostrar.Enabled = true;

}
}


junto con esto, en el evento load deshabilite los botones con otro metodo, para que desde un principio los botones estuviieran deshabilitados, saludos.