protected void btnSave_Click(object sender, EventArgs e) { SAVECLICKED = true; if (btnSave.Text == SAVE) { if (CheckFields()) { ChatRoom chatrObj = new ChatRoom(); chatrObj.Chat_name = txtChatRoom.Text; chatrObj.About = txtAbout.Text; chatrObj.Image = Session[CHATROOM_SAVE_STRING].ToString(); if (!chatrObj.CheckChatRoom()) { if (chatrObj.AddChatRoom()) { ShowMessage(Message.Success, "Chatroom Added Successfully."); ResetPage(); } else { ShowMessage(Message.Error, "Unable To Save Chatroom."); } } else { ShowMessage(Message.Warning, "Chatroom Already Exists."); } } else { ShowMessage(Message.Error, "Fill all required fields."); } } else if (btnSave.Text == UPDATE) { if (CheckFields()) { ChatRoom chatrObj = new ChatRoom(); chatrObj.Chat_r_id = int.Parse(hiddenId.Value); chatrObj.Chat_name = txtChatRoom.Text; chatrObj.About = txtAbout.Text; chatrObj.Image = Session[CHATROOM_SAVE_STRING].ToString(); if (!chatrObj.CheckChatRoomEdit()) { if (chatrObj.EditChatRoom()) { ShowMessage(Message.Success, "Chatroom Updated Successfully."); ResetPage(); } else { ShowMessage(Message.Error, "Unable To Update Chatroom."); } } else { ShowMessage(Message.Warning, "Chatroom Already Exists."); } } else { ShowMessage(Message.Error, "Fill all required fields."); } } imgChatRoom.ImageUrl = Session[CHATROOM_SAVE_STRING].ToString(); }