protected void btnsave_Click(object sender, EventArgs e) { try { if (HiddenFlag.Value == "Add") { int retval = objBLL.InsertRankCategory(txtRankcategory.Text.Trim(), Convert.ToInt32(Session["USERID"])); if (retval == 1) { BindRankCategory(); string hidemodal = String.Format("hideModal('divadd',true);"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "hidemodal", hidemodal, true); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert('Added new category successfully.' );", true); } else { BindRankCategory(); string hidemodal = String.Format("showModal('divadd',true);validatetxt();"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "hidemodal", hidemodal, true); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert('Category name already Exists.' );", true); } } else { int retval = objBLL.EditRankCategory(Convert.ToInt32(txtRankcategoryID.Text.Trim()), txtRankcategory.Text.Trim(), Convert.ToInt32(Session["USERID"])); if (retval == 1) { BindRankCategory(); string hidemodal = String.Format("hideModal('divadd',true);"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "hidemodal", hidemodal, true); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert('Updated successfully.' );", true); } else { BindRankCategory(); string hidemodal = String.Format("showModal('divadd',true);validatetxt();"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "hidemodal", hidemodal, true); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert('Category name already Exists.' );", true); } } } catch (Exception) { throw; } }