protected void btnBorrar_Click(object sender, EventArgs e) { try { Button btn = (Button)sender; Categoria categoria = CategoriaControlador.ObtenerCategoriaPorID(Convert.ToInt32(btn.Attributes["obj"])); CategoriaControlador.EliminarCategoria(categoria); Page_Load(null, null); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "error('" + ex.Message + "');", true); } }
protected void btnEditar_Click(object sender, EventArgs e) { try { Button btn = (Button)sender; Categoria categoria = CategoriaControlador.ObtenerCategoriaPorID(Convert.ToInt32(btn.Attributes["obj"])); hdnProdId.Value = categoria.id.ToString(); txtNombre.Text = categoria.nombre; chkActivo.Checked = categoria.activo; lblModal.InnerText = "Editar"; string javascript = "mostrarModal()"; ScriptManager.RegisterStartupScript(this, this.GetType(), "script", javascript, true); Page_Load(null, null); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "error('" + ex.Message + "');", true); } }