protected void btnSave_Click(object sender, EventArgs e) { if (valid()) { if (btnSave.CommandName == "Save") { controller.Save(txtDrugName.Text, DDdrugType.Text, txtStock.Text, txtExpDate.Text, txtPrice.Text); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record Inserted Successfully')", true); Response.Redirect("~/ui/Drug.aspx"); } else if (btnSave.CommandName == "Update") { if (controller.Update(Request.QueryString["ID"].ToString(), txtDrugName.Text, DDdrugType.Text, txtStock.Text, txtExpDate.Text, txtPrice.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record Update Successfully')", true); Response.Redirect("~/ui/Drug.aspx"); } } } }