Rock.Field.Types.PageReferenceFieldType.GetEditValue C# (CSharp) Method

GetEditValue() public method

Reads new values entered by the user for the field. Returns with Page.Guid,PageRoute.Guid or just Page.Guid
public GetEditValue ( System control, ConfigurationValue>.Dictionary configurationValues ) : string
control System Parent control that controls were added to in the CreateEditControl() method
configurationValues ConfigurationValue>.Dictionary The configuration values.
return string
        public override string GetEditValue( System.Web.UI.Control control, Dictionary<string, ConfigurationValue> configurationValues )
        {
            PagePicker ppPage = control as PagePicker;
            string result = null;

            if ( ppPage != null )
            {
                //// Value is in format "Page.Guid,PageRoute.Guid"
                //// If only a Page is specified, this is just a reference to a page without a special route

                if ( ppPage.IsPageRoute )
                {
                    int? pageRouteId = ppPage.PageRouteId;
                    var pageRoute = new PageRouteService( new RockContext() ).Get( pageRouteId ?? 0 );
                    if ( pageRoute != null )
                    {
                        result = string.Format( "{0},{1}", pageRoute.Page.Guid, pageRoute.Guid );
                    }
                }
                else
                {
                    var page = new PageService( new RockContext() ).Get( ppPage.PageId ?? 0 );
                    if ( page != null )
                    {
                        result = page.Guid.ToString();
                    }
                }
            }

            return result;
        }

Usage Example

Ejemplo n.º 1
0
        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( "EnableDebug", cbDebug.Checked.ToString() );
            SetAttributeValue( "MergeContent", cbMergeContent.Checked.ToString() );
            SetAttributeValue( "Template", ceTemplate.Text );
            SetAttributeValue( "Count", ( nbCount.Text.AsIntegerOrNull() ?? 5 ).ToString() );
            SetAttributeValue( "CacheDuration", ( nbCacheDuration.Text.AsIntegerOrNull() ?? 5 ).ToString() );
            SetAttributeValue( "FilterId", dataViewFilter.Id.ToString() );
            SetAttributeValue( "QueryParameterFiltering", cbQueryParamFiltering.Checked.ToString() );
            SetAttributeValue( "Order", kvlOrder.Value );
            SetAttributeValue( "SetPageTitle", cbSetPageTitle.Checked.ToString() );
            SetAttributeValue( "RssAutodiscover", cbSetRssAutodiscover.Checked.ToString() );
            SetAttributeValue( "MetaDescriptionAttribute", ddlMetaDescriptionAttribute.SelectedValue );
            SetAttributeValue( "MetaImageAttribute", ddlMetaImageAttribute.SelectedValue );

            var ppFieldType = new PageReferenceFieldType();
            SetAttributeValue( "DetailPage", ppFieldType.GetEditValue( ppDetailPage, null ) );

            SaveAttributeValues();

            FlushCacheItem( CONTENT_CACHE_KEY );
            FlushCacheItem( TEMPLATE_CACHE_KEY );

            mdEdit.Hide();
            pnlEditModal.Visible = false;
            upnlContent.Update();

            ShowView();
        }
All Usage Examples Of Rock.Field.Types.PageReferenceFieldType::GetEditValue