Exemplo n.º 1
0
        /// <summary>
        /// Handles the OnSave event of the masterPage 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 masterPage_OnSave(object sender, EventArgs e)
        {
            int        blockId = Convert.ToInt32(PageParameter("BlockId"));
            BlockCache _block  = BlockCache.Read(blockId);

            if (Page.IsValid)
            {
                using (new Rock.Data.UnitOfWorkScope())
                {
                    var blockService = new Rock.Model.BlockService();
                    var block        = blockService.Get(_block.Id);

                    block.LoadAttributes();

                    block.Name = tbBlockName.Text;
                    block.OutputCacheDuration = Int32.Parse(tbCacheDuration.Text);
                    blockService.Save(block, CurrentPersonId);

                    Rock.Attribute.Helper.GetEditValues(phAttributes, _block);
                    _block.SaveAttributeValues(CurrentPersonId);

                    Rock.Web.Cache.BlockCache.Flush(_block.Id);
                }

                string script = "window.parent.closeModal()";
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "close-modal", script, true);
            }
            else
            {
                Rock.Attribute.Helper.SetErrorIndicators(phAttributes, _block);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the OnSave event of the masterPage 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 masterPage_OnSave(object sender, EventArgs e)
        {
            int        blockId = Convert.ToInt32(PageParameter("BlockId"));
            BlockCache _block  = BlockCache.Read(blockId);

            if (Page.IsValid)
            {
                using (new Rock.Data.UnitOfWorkScope())
                {
                    var blockService = new Rock.Model.BlockService();
                    var block        = blockService.Get(_block.Id);

                    block.LoadAttributes();

                    block.Name                = tbBlockName.Text;
                    block.CssClass            = tbCssClass.Text;
                    block.PreHtml             = cePreHtml.Text;
                    block.PostHtml            = cePostHtml.Text;
                    block.OutputCacheDuration = Int32.Parse(tbCacheDuration.Text);
                    blockService.Save(block, CurrentPersonId);

                    Rock.Attribute.Helper.GetEditValues(phAttributes, _block);
                    if (phAdvancedAttributes.Controls.Count > 0)
                    {
                        Rock.Attribute.Helper.GetEditValues(phAdvancedAttributes, _block);
                    }
                    _block.SaveAttributeValues(CurrentPersonId);

                    Rock.Web.Cache.BlockCache.Flush(_block.Id);
                }

                string script = string.Format("window.parent.Rock.controls.modal.close('BLOCK_UPDATED:{0}');", blockId);
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "close-modal", script, true);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the OnSave event of the masterPage 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 masterPage_OnSave( object sender, EventArgs e )
        {
            int blockId = Convert.ToInt32( PageParameter( "BlockId" ) );
            BlockCache _block = BlockCache.Read( blockId );
            if ( Page.IsValid )
            {
                using ( new Rock.Data.UnitOfWorkScope() )
                {
                    var blockService = new Rock.Model.BlockService();
                    var block = blockService.Get( _block.Id );

                    block.LoadAttributes();

                    block.Name = tbBlockName.Text;
                    block.CssClass = tbCssClass.Text;
                    block.PreHtml = cePreHtml.Text;
                    block.PostHtml = cePostHtml.Text;
                    block.OutputCacheDuration = Int32.Parse( tbCacheDuration.Text );
                    blockService.Save( block, CurrentPersonId );

                    Rock.Attribute.Helper.GetEditValues( phAttributes, _block );
                    if ( phAdvancedAttributes.Controls.Count > 0 )
                    {
                        Rock.Attribute.Helper.GetEditValues( phAdvancedAttributes, _block );
                    }
                    _block.SaveAttributeValues( CurrentPersonId );

                    Rock.Web.Cache.BlockCache.Flush( _block.Id );
                }

                string script = string.Format( "window.parent.Rock.controls.modal.close('BLOCK_UPDATED:{0}');", blockId );
                ScriptManager.RegisterStartupScript( this.Page, this.GetType(), "close-modal", script, true );
            }
        }