private void AddSrcComboBox(TargetAudienceInfo info) { var checkBox = new CheckBox(); checkBox.CheckedChanged += this.CheckBoxCheckedChanged; checkBox.Attributes["value"] = info.ID; checkBox.AutoPostBack = true; checkBox.CssClass = "msCheckBox"; if (this.requireAuthentication) { checkBox.Checked = info.CustomData == "1"; } else { checkBox.Checked = true; } checkBox.Text = info.Name; this.SrcList.Controls.Add(checkBox); if (!String.IsNullOrEmpty(info.Description)) { this.SrcList.Controls.Add(new Literal { Text = "<div class=\"msDescription\">" + info.Description + "</div>" }); } }
/// <exception cref="EmailCampaignException"><c>EmailCampaignException</c>.</exception> protected virtual void Subscribe_click(object sender, EventArgs args) { try { if (this.RootID == null && this.ContextContact == null) { return; } if (this.requireAuthentication && (this.Email.Text != this.ContextContact.Profile.Email || string.IsNullOrEmpty(this.ContextContact.Profile.Email))) { if (!Util.IsValidEmail(this.Email.Text)) { throw new EmailCampaignException(Util.GetFrontEndText("email not valid")); } string text = Util.GetFrontEndText("address changed confirmation"); this.AddConfirmationDlg(string.Format(text, Util.GetFrontEndText("an email"))); return; } TargetAudienceInfo[] infoArray; if (this.showList) { List<CheckBox> items = this.GetSrcListItems(); infoArray = new TargetAudienceInfo[items.Count]; for (int i = 0; i < infoArray.Length; i++) { CheckBox checkBox = items[i]; infoArray[i] = new TargetAudienceInfo { ID = checkBox.Attributes["value"], CustomData = checkBox.Checked ? "1" : "0", Name = string.Empty, Description = string.Empty }; } } else { for (int i = 0; i < this.TargetAudiencesInfo.Length; i++) { this.TargetAudiencesInfo[i].CustomData = "1"; this.TargetAudiencesInfo[i].Name = string.Empty; this.TargetAudiencesInfo[i].Description = string.Empty; } infoArray = this.TargetAudiencesInfo; } string itemIDToRedirect = ClientApi.UpdateSubscriptions(this.ContextContact.Name, infoArray, this.confirmSubscription); if (!string.IsNullOrEmpty(itemIDToRedirect)) { string url = ItemUtilExt.GetContentItemPageUrl(itemIDToRedirect); if (!string.IsNullOrEmpty(url)) { WebUtil.Redirect(url); } } } catch (EmailCampaignException e) { this.Warning.InnerText = e.LocalizedMessage; } catch (Exception e) { this.Warning.InnerText = Util.GetFrontEndText(e.Message); Logging.LogError(e); } }