protected void btnAddAnnouncement_Click(object sender, EventArgs e) { try { if (txtAnnouncement.Text.Length > 0) { if (ddlAnnouncementTo.SelectedIndex == 0) { DropDownList ddlPropertyName = (DropDownList)Master.FindControl("ddlProperty"); string PropertyName = ddlPropertyName.SelectedItem.Text; string PropertyVale = ddlPropertyName.SelectedValue; if (PropertyVale != "0") { ddlAnnouncementTo.SelectedItem.Text = "all"; ddlAnnouncementTo.SelectedItem.Value = "0"; string mobile = Session["s_MobileNo"].ToString(); uc.AddAnnouncement(mobile, PropertyName, PropertyVale, ddlAnnouncementTo.SelectedItem.Text, ddlAnnouncementTo.SelectedItem.Value, txtAnnouncementToMobile.Text, txtAnnouncement.Text); string textmsg = " Announcement Added Successfully"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Warning", "<script>showpopsuccess('" + textmsg + "')</script>", false); ddlAnnouncementTo.ClearSelection(); txtAnnouncementToMobile.Text = string.Empty; txtAnnouncement.Text = string.Empty; btnAddAnnouncement.Visible = true; btnSaveChenges.Visible = false; } else { string errormsg = "Please Select property name"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Warning", "<script>showpoperror('" + errormsg + "')</script>", false); } } else { DropDownList ddlPropertyName = (DropDownList)Master.FindControl("ddlProperty"); string PropertyName = ddlPropertyName.SelectedItem.Text; string PropertyVale = ddlPropertyName.SelectedValue; if (PropertyVale != "0") { string mobile = Session["s_MobileNo"].ToString(); uc.AddAnnouncement(mobile, PropertyName, PropertyVale, ddlAnnouncementTo.SelectedItem.Text, ddlAnnouncementTo.SelectedItem.Value, txtAnnouncementToMobile.Text, txtAnnouncement.Text); string textmsg = " Announcement Added Successfully"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Warning", "<script>showpopsuccess('" + textmsg + "')</script>", false); ddlAnnouncementTo.ClearSelection(); txtAnnouncementToMobile.Text = string.Empty; txtAnnouncement.Text = string.Empty; } else { string errormsg = "Please Select property name"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Warning", "<script>showpoperror('" + errormsg + "')</script>", false); } } } else { string exrmsg = "Please Enter Announcement Details"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Warning", "<script>showpoperror('" + exrmsg + "')</script>", false); } } catch (Exception ex) { string exrmsg = ex.Message.ToString(); ScriptManager.RegisterStartupScript(this, typeof(Page), "Warning", "<script>showpoperror('" + exrmsg + "')</script>", false); } }