protected void lbSave_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } SetAttributeValue("Group", ddlGroup.SelectedValue); SetAttributeValue("Template", ceTemplate.Text); SetAttributeValue("CacheDuration", (nbItemCacheDuration.Text.AsIntegerOrNull() ?? 0).ToString()); SetAttributeValue("OutputCacheDuration", (nbOutputCacheDuration.Text.AsIntegerOrNull() ?? 0).ToString()); var ppFieldType = new PageReferenceFieldType(); SetAttributeValue("DetailPage", ppFieldType.GetEditValue(ppDetailPage, null)); SaveAttributeValues(); FlushCacheItem(CONTENT_CACHE_KEY); FlushCacheItem(TEMPLATE_CACHE_KEY); FlushCacheItem(OUTPUT_CACHE_KEY); mdEdit.Hide(); pnlEditModal.Visible = false; upnlContent.Update(); ShowView(); }
/// <summary> /// Shows the settings. /// </summary> protected override void ShowSettings() { mdEdit.Show(); var rockContext = new RockContext(); cblAllowedChannelTypes.DataSource = new ContentChannelTypeService(rockContext).Queryable() .OrderBy(c => c.Name) .Select(c => new { c.Guid, c.Name }) .ToList(); cblAllowedChannelTypes.DataBind(); ddlLayout.SetValue(GetAttributeValue("Layout")); var ppFieldType = new PageReferenceFieldType(); ppFieldType.SetEditValue(ppDetailPage, null, GetAttributeValue("DetailPage")); cblAllowedChannelTypes.SetValues(GetAttributeValues("AllowedChannelTypes")); ddlSortItemsBy.SetValue(GetAttributeValue("SortItemsBy")); var binaryFile = new BinaryFileService(rockContext).Get(GetAttributeValue("BackgroundImage").AsGuid()); ftBackgroundImage.BinaryFileId = binaryFile != null ? ( int? )binaryFile.Id : null; tbBackgroundImageUrl.Text = GetAttributeValue("BackgroundImageUrl"); ceTemplate.Text = GetAttributeValue("Template"); }
/// <summary> /// Binds the workflow type picker. /// </summary> private void BindPagePickerControls() { if (_hasLaunched) { ppCommunicationPage.Visible = false; return; } // If a page parameter is set, then it overrides everything else var communicationPageId = PageParameter(PageParameterKey.CommunicationPageId).AsIntegerOrNull(); var selectedPage = GetAttributeValue(AttributeKey.CommunicationPage); if (communicationPageId.HasValue) { var communicationPage = PageCache.Get(communicationPageId.Value); if (communicationPage != null && communicationPage.IsAuthorized(Authorization.VIEW, CurrentPerson)) { ppCommunicationPage.Visible = false; return; } } else if (selectedPage.IsNotNullOrWhiteSpace()) { var ppFieldType = new PageReferenceFieldType(); ppFieldType.SetEditValue(ppCommunicationPage, null, selectedPage); } }
protected void lbSave_Click(object sender, EventArgs e) { var dataViewFilter = GetFilterControl(); // update Guids since we are creating a new dataFilter and children and deleting the old one SetNewDataFilterGuids(dataViewFilter); if (!Page.IsValid) { return; } if (!dataViewFilter.IsValid) { // Controls will render the error messages return; } var rockContext = new RockContext(); DataViewFilterService dataViewFilterService = new DataViewFilterService(rockContext); int?dataViewFilterId = hfDataFilterId.Value.AsIntegerOrNull(); if (dataViewFilterId.HasValue) { var oldDataViewFilter = dataViewFilterService.Get(dataViewFilterId.Value); DeleteDataViewFilter(oldDataViewFilter, dataViewFilterService); } dataViewFilterService.Add(dataViewFilter); rockContext.SaveChanges(); SetAttributeValue("Status", cblStatus.SelectedValuesAsInt.AsDelimited(",")); SetAttributeValue("Channel", ddlChannel.SelectedValue); SetAttributeValue("Count", (nbCount.Text.AsIntegerOrNull() ?? 5).ToString()); SetAttributeValue("CacheDuration", (nbItemCacheDuration.Text.AsIntegerOrNull() ?? 0).ToString()); SetAttributeValue("OutputCacheDuration", (nbOutputCacheDuration.Text.AsIntegerOrNull() ?? 0).ToString()); SetAttributeValue("FilterId", dataViewFilter.Id.ToString()); SetAttributeValue("Order", kvlOrder.Value); SetAttributeValue("TitleLava", tbTitleLava.Text); SetAttributeValue("IconLava", tbIconLava.Text); SetAttributeValue("ImageLava", tbImageLava.Text); SetAttributeValue("SubtitleLava", tbSubtitleLava.Text); SetAttributeValue("OrderLava", tbOrder.Text); var ppFieldType = new PageReferenceFieldType(); SetAttributeValue("DetailPage", ppFieldType.GetEditValue(ppDetailPage, null)); SaveAttributeValues(); FlushCacheItem(CONTENT_CACHE_KEY); FlushCacheItem(TEMPLATE_CACHE_KEY); FlushCacheItem(OUTPUT_CACHE_KEY); mdEdit.Hide(); pnlEditModal.Visible = false; upnlContent.Update(); }
/// <summary> /// Handles the SaveClick event of the mdSettings control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void mdSettings_SaveClick(object sender, EventArgs e) { this.SetAttributeValue("ContentChannel", ddlContentChannel.SelectedValue); this.SetAttributeValue("Status", cblStatus.SelectedValuesAsInt.AsDelimited(",")); var ppFieldType = new PageReferenceFieldType(); this.SetAttributeValue("DetailPage", ppFieldType.GetEditValue(ppDetailPage, null)); this.SetAttributeValue("ContentChannelQueryParameter", tbContentChannelQueryParameter.Text); this.SetAttributeValue("LavaTemplate", ceLavaTemplate.Text); this.SetAttributeValue("OutputCacheDuration", nbOutputCacheDuration.Text); this.SetAttributeValue("ItemCacheDuration", nbItemCacheDuration.Text); this.SetAttributeValue("CacheTags", cblCacheTags.SelectedValues.AsDelimited(",")); this.SetAttributeValue("MergeContent", cbMergeContent.Checked.ToString()); this.SetAttributeValue("SetPageTitle", cbSetPageTitle.Checked.ToString()); this.SetAttributeValue("LogInteractions", cbLogInteractions.Checked.ToString()); this.SetAttributeValue("WriteInteractionOnlyIfIndividualLoggedIn", cbWriteInteractionOnlyIfIndividualLoggedIn.Checked.ToString()); int? selectedWorkflowTypeId = wtpWorkflowType.SelectedValueAsId(); Guid?selectedWorkflowTypeGuid = null; if (selectedWorkflowTypeId.HasValue) { selectedWorkflowTypeGuid = WorkflowTypeCache.Get(selectedWorkflowTypeId.Value).Guid; } this.SetAttributeValue("WorkflowType", selectedWorkflowTypeGuid.ToString()); this.SetAttributeValue("LaunchWorkflowOnlyIfIndividualLoggedIn", cbLaunchWorkflowOnlyIfIndividualLoggedIn.Checked.ToString()); this.SetAttributeValue("LaunchWorkflowCondition", ddlLaunchWorkflowCondition.SelectedValue); this.SetAttributeValue("MetaDescriptionAttribute", ddlMetaDescriptionAttribute.SelectedValue); this.SetAttributeValue("OpenGraphType", ddlOpenGraphType.SelectedValue); this.SetAttributeValue("OpenGraphTitleAttribute", ddlOpenGraphTitleAttribute.SelectedValue); this.SetAttributeValue("OpenGraphDescriptionAttribute", ddlOpenGraphDescriptionAttribute.SelectedValue); this.SetAttributeValue("OpenGraphImageAttribute", ddlOpenGraphImageAttribute.SelectedValue); this.SetAttributeValue("TwitterTitleAttribute", ddlTwitterTitleAttribute.SelectedValue); this.SetAttributeValue("TwitterDescriptionAttribute", ddlTwitterDescriptionAttribute.SelectedValue); this.SetAttributeValue("TwitterImageAttribute", ddlTwitterImageAttribute.SelectedValue); this.SetAttributeValue("TwitterCard", ddlTwitterCard.SelectedValue); SaveAttributeValues(); var cacheKeys = GetCacheItem(CACHEKEYS_CACHE_KEY) as HashSet <string>; if (cacheKeys != null) { foreach (var cacheKey in cacheKeys) { RemoveCacheItem(cacheKey); } } RemoveCacheItem(CACHEKEYS_CACHE_KEY); mdSettings.Hide(); pnlSettings.Visible = false; // reload the page to make sure we have a clean load NavigateToCurrentPageReference(); }
/// <summary> /// Handles the SaveClick event of the mdEdit control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void mdEdit_SaveClick(object sender, EventArgs e) { if (!Page.IsValid) { return; } var rockContext = new RockContext(); // // Delete the old file and persist the new file - if they are different. // var binaryFileService = new BinaryFileService(rockContext); var oldBinaryFileGuid = GetAttributeValue("BackgroundImage").AsGuidOrNull(); var newBinaryFile = binaryFileService.Get(ftBackgroundImage.BinaryFileId ?? 0); if (oldBinaryFileGuid.HasValue && (newBinaryFile == null || oldBinaryFileGuid.Value != newBinaryFile.Guid)) { var oldBinaryFile = binaryFileService.Get(oldBinaryFileGuid.Value); if (oldBinaryFile != null) { oldBinaryFile.IsTemporary = true; } } if (newBinaryFile != null && (!oldBinaryFileGuid.HasValue || newBinaryFile.Guid != oldBinaryFileGuid.Value)) { newBinaryFile.IsTemporary = false; } rockContext.SaveChanges(); SetAttributeValue("Layout", ddlLayout.SelectedValue); SetAttributeValue("AllowedChannelTypes", cblAllowedChannelTypes.SelectedValues.AsDelimited(",")); SetAttributeValue("SortItemsBy", ddlSortItemsBy.SelectedValue); var ppFieldType = new PageReferenceFieldType(); SetAttributeValue("DetailPage", ppFieldType.GetEditValue(ppDetailPage, null)); SetAttributeValue("BackgroundImage", newBinaryFile != null ? newBinaryFile.Guid.ToString() : string.Empty); SetAttributeValue("BackgroundImageUrl", tbBackgroundImageUrl.Text); SetAttributeValue("Template", ceTemplate.Text); SaveAttributeValues(); mdEdit.Hide(); ShowPreview(); }
/// <summary> /// Shows the settings. /// </summary> protected override void ShowSettings() { pnlSettings.Visible = true; cbShowBlockTitle.Checked = GetAttributeValue(AttributeKey.ShowBlockTitle).AsBoolean(); rtbBlockTitleText.Text = GetAttributeValue(AttributeKey.BlockTitleText); rtbBlockTitleIconCssClass.Text = GetAttributeValue(AttributeKey.BlockTitleIconCssClass); nbFiltersPerRow.Text = GetAttributeValue(AttributeKey.FiltersPerRow); cbShowResetFiltersButton.Checked = GetAttributeValue(AttributeKey.ShowResetFiltersButton).AsBoolean(); rtbFilterButtonText.Text = GetAttributeValue(AttributeKey.FilterButtonText); ddlFilterButtonSize.SetValue(GetAttributeValue(AttributeKey.FilterButtonSize).AsInteger()); var ppFieldType = new PageReferenceFieldType(); ppFieldType.SetEditValue(ppRedirectPage, null, GetAttributeValue(AttributeKey.RedirectPage)); cbDoesSelectionCausePostback.Checked = GetAttributeValue(AttributeKey.DoesSelectionCausePostback).AsBoolean(); BindGrid(); mdSettings.Show(); }
/// <summary> /// Shows the settings. /// </summary> protected override void ShowSettings() { // Switch does not automatically initialize again after a partial-postback. This script // looks for any switch elements that have not been initialized and re-intializes them. string script = @" $(document).ready(function() { $('.switch > input').each( function () { $(this).parent().switch('init'); }); }); "; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "toggle-switch-init", script, true); pnlEditModal.Visible = true; upnlContent.Update(); mdEdit.Show(); var rockContext = new RockContext(); ddlGroup.DataSource = new GroupService(rockContext).Queryable() .OrderBy(c => c.Name) .Select(c => new { c.Guid, c.Name }) .ToList(); ddlGroup.DataBind(); ddlGroup.Items.Insert(0, new ListItem("", "")); ddlGroup.SetValue(GetAttributeValue("Group")); GroupGuid = ddlGroup.SelectedValue.AsGuidOrNull(); ceTemplate.Text = GetAttributeValue("Template"); nbItemCacheDuration.Text = GetAttributeValue("CacheDuration"); nbOutputCacheDuration.Text = GetAttributeValue("OutputCacheDuration"); var ppFieldType = new PageReferenceFieldType(); ppFieldType.SetEditValue(ppDetailPage, null, GetAttributeValue("DetailPage")); ShowEdit(); upnlContent.Update(); }
/// <summary> /// Handles the SaveClick event of the mdSettings control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void mdSettings_SaveClick(object sender, EventArgs e) { SetAttributeValue(AttributeKey.ShowBlockTitle, cbShowBlockTitle.Checked.ToString()); SetAttributeValue(AttributeKey.BlockTitleText, rtbBlockTitleText.Text); SetAttributeValue(AttributeKey.BlockTitleIconCssClass, rtbBlockTitleIconCssClass.Text); SetAttributeValue(AttributeKey.FiltersPerRow, nbFiltersPerRow.Text); SetAttributeValue(AttributeKey.ShowResetFiltersButton, cbShowResetFiltersButton.Checked.ToString()); SetAttributeValue(AttributeKey.FilterButtonText, rtbFilterButtonText.Text); SetAttributeValue(AttributeKey.FilterButtonSize, ddlFilterButtonSize.SelectedValue); var ppFieldType = new PageReferenceFieldType(); SetAttributeValue(AttributeKey.RedirectPage, ppFieldType.GetEditValue(ppRedirectPage, null)); SetAttributeValue(AttributeKey.DoesSelectionCausePostback, cbDoesSelectionCausePostback.Checked.ToString()); SaveAttributeValues(); mdSettings.Hide(); pnlSettings.Visible = false; // reload the page to make sure we have a clean load ResetFilters(); NavigateToCurrentPageReference(); }
/// <summary> /// Shows the settings. /// </summary> protected override void ShowSettings() { pnlSettings.Visible = true; ddlContentChannel.Items.Clear(); ddlContentChannel.Items.Add(new ListItem()); foreach (var contentChannel in ContentChannelCache.All().OrderBy(a => a.Name)) { ddlContentChannel.Items.Add(new ListItem(contentChannel.Name, contentChannel.Guid.ToString())); } ddlLaunchWorkflowCondition.Items.Clear(); foreach (LaunchWorkflowCondition launchWorkflowCondition in Enum.GetValues(typeof(LaunchWorkflowCondition))) { ddlLaunchWorkflowCondition.Items.Add(new ListItem(launchWorkflowCondition.ConvertToString(true), launchWorkflowCondition.ConvertToInt().ToString())); } var channelGuid = this.GetAttributeValue("ContentChannel").AsGuidOrNull(); ddlContentChannel.SetValue(channelGuid); UpdateSocialMediaDropdowns(channelGuid); cblStatus.BindToEnum <ContentChannelItemStatus>(); foreach (string status in GetAttributeValue("Status").SplitDelimitedValues()) { var li = cblStatus.Items.FindByValue(status); if (li != null) { li.Selected = true; } } var ppFieldType = new PageReferenceFieldType(); ppFieldType.SetEditValue(ppDetailPage, null, GetAttributeValue("DetailPage")); tbContentChannelQueryParameter.Text = this.GetAttributeValue("ContentChannelQueryParameter"); ceLavaTemplate.Text = this.GetAttributeValue("LavaTemplate"); nbOutputCacheDuration.Text = this.GetAttributeValue("OutputCacheDuration"); nbItemCacheDuration.Text = this.GetAttributeValue("ItemCacheDuration"); DefinedValueService definedValueService = new DefinedValueService(new RockContext()); cblCacheTags.DataSource = definedValueService.GetByDefinedTypeGuid(Rock.SystemGuid.DefinedType.CACHE_TAGS.AsGuid()).Select(v => v.Value).ToList(); cblCacheTags.DataBind(); string[] selectedCacheTags = this.GetAttributeValue("CacheTags").SplitDelimitedValues(); foreach (ListItem cacheTag in cblCacheTags.Items) { cacheTag.Selected = selectedCacheTags.Contains(cacheTag.Value); } cbSetPageTitle.Checked = this.GetAttributeValue("SetPageTitle").AsBoolean(); cbMergeContent.Checked = GetAttributeValue("MergeContent").AsBoolean(); if (this.GetAttributeValue("LogInteractions").AsBoolean()) { cbLogInteractions.Checked = true; cbWriteInteractionOnlyIfIndividualLoggedIn.Visible = true; cbWriteInteractionOnlyIfIndividualLoggedIn.Checked = this.GetAttributeValue("WriteInteractionOnlyIfIndividualLoggedIn").AsBoolean(); } else { cbLogInteractions.Checked = false; cbWriteInteractionOnlyIfIndividualLoggedIn.Visible = false; cbWriteInteractionOnlyIfIndividualLoggedIn.Checked = false; } var rockContext = new RockContext(); // Workflow Guid?workflowTypeGuid = this.GetAttributeValue("WorkflowType").AsGuidOrNull(); if (workflowTypeGuid.HasValue) { wtpWorkflowType.SetValue(new WorkflowTypeService(rockContext).GetNoTracking(workflowTypeGuid.Value)); } else { wtpWorkflowType.SetValue(null); } ShowHideControls(); cbLaunchWorkflowOnlyIfIndividualLoggedIn.Checked = this.GetAttributeValue("LaunchWorkflowOnlyIfIndividualLoggedIn").AsBoolean(); ddlLaunchWorkflowCondition.SetValue(this.GetAttributeValue("LaunchWorkflowCondition")); // Social Media ddlMetaDescriptionAttribute.SetValue(this.GetAttributeValue("MetaDescriptionAttribute")); ddlOpenGraphType.SetValue(this.GetAttributeValue("OpenGraphType")); ddlOpenGraphTitleAttribute.SetValue(this.GetAttributeValue("OpenGraphTitleAttribute")); ddlOpenGraphDescriptionAttribute.SetValue(this.GetAttributeValue("OpenGraphDescriptionAttribute")); ddlOpenGraphImageAttribute.SetValue(this.GetAttributeValue("OpenGraphImageAttribute")); ddlTwitterTitleAttribute.SetValue(this.GetAttributeValue("TwitterTitleAttribute")); ddlTwitterDescriptionAttribute.SetValue(this.GetAttributeValue("TwitterDescriptionAttribute")); ddlTwitterImageAttribute.SetValue(this.GetAttributeValue("TwitterImageAttribute")); ddlTwitterCard.SetValue(this.GetAttributeValue("TwitterCard")); mdSettings.Show(); }
/// <summary> /// Shows the settings. /// </summary> protected override void ShowSettings() { // Switch does not automatically initialize again after a partial-postback. This script // looks for any switch elements that have not been initialized and re-intializes them. string script = @" $(document).ready(function() { $('.switch > input').each( function () { $(this).parent().switch('init'); }); }); "; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "toggle-switch-init", script, true); pnlEditModal.Visible = true; upnlContent.Update(); mdEdit.Show(); var rockContext = new RockContext(); ddlChannel.DataSource = new ContentChannelService(rockContext).Queryable() .OrderBy(c => c.Name) .Select(c => new { c.Guid, c.Name }) .ToList(); ddlChannel.DataBind(); ddlChannel.Items.Insert(0, new ListItem("", "")); ddlChannel.SetValue(GetAttributeValue("Channel")); ChannelGuid = ddlChannel.SelectedValue.AsGuidOrNull(); cblStatus.BindToEnum <ContentChannelItemStatus>(); foreach (string status in GetAttributeValue("Status").SplitDelimitedValues()) { var li = cblStatus.Items.FindByValue(status); if (li != null) { li.Selected = true; } } nbCount.Text = GetAttributeValue("Count"); nbItemCacheDuration.Text = GetAttributeValue("CacheDuration"); nbOutputCacheDuration.Text = GetAttributeValue("OutputCacheDuration"); hfDataFilterId.Value = GetAttributeValue("FilterId"); tbTitleLava.Text = GetAttributeValue("TitleLava"); tbIconLava.Text = GetAttributeValue("IconLava"); tbImageLava.Text = GetAttributeValue("ImageLava"); tbSubtitleLava.Text = GetAttributeValue("SubtitleLava"); var ppFieldType = new PageReferenceFieldType(); ppFieldType.SetEditValue(ppDetailPage, null, GetAttributeValue("DetailPage")); var directions = new Dictionary <string, string>(); directions.Add("", ""); directions.Add(SortDirection.Ascending.ConvertToInt().ToString(), "Ascending"); directions.Add(SortDirection.Descending.ConvertToInt().ToString(), "Descending"); kvlOrder.CustomValues = directions; kvlOrder.Value = GetAttributeValue("Order"); kvlOrder.Required = true; ShowEdit(); upnlContent.Update(); }
/// <summary> /// Handles the SaveClick event of the mdEdit control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void mdEdit_SaveClick(object sender, EventArgs e) { var dataViewFilter = GetFilterControl(); // update Guids since we are creating a new dataFilter and children and deleting the old one SetNewDataFilterGuids(dataViewFilter); if (!Page.IsValid) { return; } if (!dataViewFilter.IsValid) { // Controls will render the error messages return; } var rockContext = new RockContext(); DataViewFilterService dataViewFilterService = new DataViewFilterService(rockContext); int?dataViewFilterId = hfDataFilterId.Value.AsIntegerOrNull(); if (dataViewFilterId.HasValue) { var oldDataViewFilter = dataViewFilterService.Get(dataViewFilterId.Value); DeleteDataViewFilter(oldDataViewFilter, dataViewFilterService); } dataViewFilterService.Add(dataViewFilter); // // Delete the old file and persist the new file - if they are different. // var binaryFileService = new BinaryFileService(rockContext); var oldBinaryFileGuid = GetAttributeValue("BackgroundImage").AsGuidOrNull(); var newBinaryFile = binaryFileService.Get(ftBackgroundImage.BinaryFileId ?? 0); if (oldBinaryFileGuid.HasValue && (newBinaryFile == null || oldBinaryFileGuid.Value != newBinaryFile.Guid)) { var oldBinaryFile = binaryFileService.Get(oldBinaryFileGuid.Value); if (oldBinaryFile != null) { oldBinaryFile.IsTemporary = true; } } if (newBinaryFile != null && (!oldBinaryFileGuid.HasValue || newBinaryFile.Guid != oldBinaryFileGuid.Value)) { newBinaryFile.IsTemporary = false; } rockContext.SaveChanges(); SetAttributeValue("ContentChannel", ddlChannel.SelectedValue); SetAttributeValue("Status", cblStatus.SelectedValuesAsInt.AsDelimited(",")); SetAttributeValue("Layout", ddlLayout.SelectedValue); var ppFieldType = new PageReferenceFieldType(); SetAttributeValue("DetailPage", ppFieldType.GetEditValue(ppDetailPage, null)); SetAttributeValue("FilterId", dataViewFilter.Id.ToString()); SetAttributeValue("Order", kvlOrder.Value); SetAttributeValue("BackgroundImage", newBinaryFile != null ? newBinaryFile.Guid.ToString() : string.Empty); SetAttributeValue("BackgroundImageUrl", tbBackgroundImageUrl.Text); SetAttributeValue("Template", ceTemplate.Text); SaveAttributeValues(); mdEdit.Hide(); ShowPreview(); }
/// <summary> /// Shows the settings. /// </summary> protected override void ShowSettings() { // Switch does not automatically initialize again after a partial-postback. This script // looks for any switch elements that have not been initialized and re-intializes them. string script = @" ;$(document).ready(function() { $('.switch > input').each( function () { $(this).parent().switch('init'); }); }); "; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "toggle-switch-init", script, true); mdEdit.Show(); var rockContext = new RockContext(); ddlChannel.DataSource = new ContentChannelService(rockContext).Queryable() .OrderBy(c => c.Name) .Select(c => new { c.Guid, c.Name }) .ToList(); ddlChannel.DataBind(); ddlChannel.Items.Insert(0, new ListItem("", "")); ddlChannel.SetValue(GetAttributeValue("ContentChannel")); cblStatus.BindToEnum <ContentChannelItemStatus>(); foreach (string status in GetAttributeValue("Status").SplitDelimitedValues()) { var li = cblStatus.Items.FindByValue(status); if (li != null) { li.Selected = true; } } ddlLayout.SetValue(GetAttributeValue("Layout")); var ppFieldType = new PageReferenceFieldType(); ppFieldType.SetEditValue(ppDetailPage, null, GetAttributeValue("DetailPage")); hfDataFilterId.Value = GetAttributeValue("FilterId"); var directions = new Dictionary <string, string> { { "", "" }, { SortDirection.Ascending.ConvertToInt().ToString(), "Ascending" }, { SortDirection.Descending.ConvertToInt().ToString(), "Descending" } }; kvlOrder.CustomValues = directions; kvlOrder.Value = GetAttributeValue("Order"); kvlOrder.Required = true; var binaryFile = new BinaryFileService(rockContext).Get(GetAttributeValue("BackgroundImage").AsGuid()); ftBackgroundImage.BinaryFileId = binaryFile != null ? ( int? )binaryFile.Id : null; tbBackgroundImageUrl.Text = GetAttributeValue("BackgroundImageUrl"); ceTemplate.Text = GetAttributeValue("Template"); ShowEdit(ddlChannel.SelectedValue.AsGuidOrNull()); }