protected void btnAgregarUsuario_Click(object sender, EventArgs e) { try { using (ControladorUsuarios c_usu = new ControladorUsuarios()) { Usuario u = new Usuario(); u.Clave = txtClave.Text; if (txtFechaBaja.Text != string.Empty) { u.FechaBaja = Convert.ToDateTime(txtFechaBaja.Text); } u.NombreApellido = txtNombre.Text; u.NombreUsuario = txtNombreUsuario.Text; c_usu.AgregarUsuario(u); } bindGrid(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#addModal').modal('hide');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AddHideModalScript", sb.ToString(), false); PanelMensaje.Visible = true; LabelMensaje.Text = "Usuario Agregado Con Exito"; System.Text.StringBuilder sb1 = new System.Text.StringBuilder(); sb1.Append(@"<script type='text/javascript'>"); sb1.Append("var focalizar = $('#MainContent_btnNuevoUsuario').position().top;"); sb1.Append("$('html,body').animate({scrollTop: focalizar}, 500);"); sb1.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", sb1.ToString(), false); } catch (ExcepcionPropia myEx) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#addModal').modal('hide');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AddHideModalScript", sb.ToString(), false); PanelError.Visible = true; lblError.Text = myEx.Message; System.Text.StringBuilder sb1 = new System.Text.StringBuilder(); sb1.Append(@"<script type='text/javascript'>"); sb1.Append("var focalizar = $('#MainContent_btnNuevoUsuario').position().top;"); sb1.Append("$('html,body').animate({scrollTop: focalizar}, 500);"); sb1.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", sb1.ToString(), false); } catch (FormatException myEx) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#addModal').modal('hide');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AddHideModalScript", sb.ToString(), false); PanelError.Visible = true; lblError.Text = myEx.Message; System.Text.StringBuilder sb1 = new System.Text.StringBuilder(); sb1.Append(@"<script type='text/javascript'>"); sb1.Append("var focalizar = $('#MainContent_btnNuevoUsuario').position().top;"); sb1.Append("$('html,body').animate({scrollTop: focalizar}, 500);"); sb1.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", sb1.ToString(), false); } }