protected void btnOk_Click(object sender, EventArgs e) { Category oldCategory = (Category)Session["OLDCATEGORY"]; Category newCategory = new Category(); newCategory.Name = txtCity.Text; if (Session["EDITMODE"] == null || !(bool)Session["EDITMODE"]) { client.AddCategory(newCategory); } else { client.ModifyCategory(oldCategory, newCategory); Session["EDITMODE"] = false; Session["OLDCATEGORY"] = null; } txtCity.Text = ""; pnlCity.Visible = false; Response.Redirect(Request.RawUrl); }