protected void InitNewsletterSelector() { // Show/hide newsletter list plcNwsList.Visible = NewsletterName.EqualsCSafe("nwsletuserchoose", true); if (plcNwsList.Visible) { chooseMode = true; if ((!ExternalUse || !RequestHelper.IsPostBack()) && (chklNewsletters.Items.Count == 0)) { DataSet ds = null; // Try to get data from cache using (CachedSection <DataSet> cs = new CachedSection <DataSet>(ref ds, CacheMinutes, true, CacheItemName, "newslettersubscription", CMSContext.CurrentSiteName)) { if (cs.LoadData) { // Get the data ds = NewsletterInfoProvider.GetAllNewslettersForSite(CMSContext.CurrentSiteID, "NewsletterDisplayName", 0, "NewsletterDisplayName,NewsletterName"); // Add data to the cache if (cs.Cached) { // Prepare cache dependency cs.CacheDependency = CacheHelper.GetCacheDependency("newsletter.newsletter|all"); } cs.Data = ds; } } if (!DataHelper.DataSourceIsEmpty(ds)) { ListItem li = null; string displayName = null; // Fill checkbox list with newsletters foreach (DataRow dr in ds.Tables[0].Rows) { // Get localized string displayName = ResHelper.LocalizeString(ValidationHelper.GetString(dr["NewsletterDisplayName"], string.Empty)); li = new ListItem(HTMLHelper.HTMLEncode(displayName), ValidationHelper.GetString(dr["NewsletterName"], string.Empty)); chklNewsletters.Items.Add(li); } } } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { } else { lblFirstName.Text = FirstNameText; lblLastName.Text = LastNameText; lblEmail.Text = EmailText; lblCaptcha.ResourceString = CaptchaText; plcCaptcha.Visible = DisplayCaptcha; if ((UseImageButton) && (!String.IsNullOrEmpty(ImageButtonURL))) { pnlButtonSubmit.Visible = false; pnlImageSubmit.Visible = true; btnImageSubmit.ImageUrl = ImageButtonURL; } else { pnlButtonSubmit.Visible = true; pnlImageSubmit.Visible = false; btnSubmit.Text = ButtonText; } // Display labels only if user is logged in and property AllowUserSubscribers is set to true if (AllowUserSubscribers && CMSContext.CurrentUser.IsAuthenticated()) { visibleFirstName = false; visibleLastName = false; visibleEmail = false; } // Otherwise display text-boxes else { visibleFirstName = true; visibleLastName = true; visibleEmail = true; } // Hide first name field if not required if (!DisplayFirstName) { visibleFirstName = false; } // Hide last name field if not required if (!DisplayLastName) { visibleLastName = false; } // Show/hide newsletter list plcNwsList.Visible = NewsletterName.EqualsCSafe("nwsletuserchoose", true); if (plcNwsList.Visible) { chooseMode = true; if ((!ExternalUse || !RequestHelper.IsPostBack()) && (chklNewsletters.Items.Count == 0)) { DataSet ds = null; // Try to get data from cache using (CachedSection <DataSet> cs = new CachedSection <DataSet>(ref ds, CacheMinutes, true, CacheItemName, "newslettersubscription", CMSContext.CurrentSiteName)) { if (cs.LoadData) { // Get the data ds = NewsletterInfoProvider.GetAllNewslettersForSite(CMSContext.CurrentSiteID, "NewsletterDisplayName", 0, "NewsletterDisplayName,NewsletterName"); // Add data to the cache if (cs.Cached) { // Prepare cache dependency cs.CacheDependency = CacheHelper.GetCacheDependency("newsletter.newsletter|all"); } cs.Data = ds; } } if (!DataHelper.DataSourceIsEmpty(ds)) { ListItem li = null; string displayName = null; // Fill checkbox list with newsletters foreach (DataRow dr in ds.Tables[0].Rows) { displayName = ResHelper.LocalizeString(ValidationHelper.GetString(dr["NewsletterDisplayName"], string.Empty)); li = new ListItem(HTMLHelper.HTMLEncode(displayName), ValidationHelper.GetString(dr["NewsletterName"], string.Empty)); chklNewsletters.Items.Add(li); } } } } // Set SkinID properties if (!StandAlone && (PageCycle < PageCycleEnum.Initialized) && (string.IsNullOrEmpty(ValidationHelper.GetString(Page.StyleSheetTheme, string.Empty)))) { string skinId = SkinID; if (!string.IsNullOrEmpty(skinId)) { lblFirstName.SkinID = skinId; lblLastName.SkinID = skinId; lblEmail.SkinID = skinId; txtFirstName.SkinID = skinId; txtLastName.SkinID = skinId; txtEmail.SkinID = skinId; btnSubmit.SkinID = skinId; } } } }