コード例 #1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CurrentParameters = this.RockPage.PageParameters();

                var query = new AttributeService(new RockContext()).Get(_blockTypeEntityId, "Id", _block.Id.ToString());
                var attribsWithDefaultValue = query.AsQueryable().Where(a => a.DefaultValue != null && a.DefaultValue != "").ToList();

                // If we have any filters with default values, we want to load this block with the page parameters already set.
                if (attribsWithDefaultValue.Any() && !this.RockPage.PageParameters().Any())
                {
                    ResetFilters();
                }
                else
                {
                    LoadFilters();
                }
            }
            else
            {
                LoadFilters();
            }

            base.OnLoad(e);

            var hideFilterButtons = GetAttributeValue(AttributeKey.HideFilterActions).AsBoolean();

            btnFilter.Visible       = !hideFilterButtons;
            btnResetFilters.Visible = !hideFilterButtons;
        }
コード例 #2
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CurrentParameters = this.RockPage.PageParameters();

                var query = new AttributeService(new RockContext()).Get(_blockTypeEntityId, "Id", _block.Id.ToString());
                var attribsWithDefaultValue = query.AsQueryable().Where(a => a.DefaultValue != null && a.DefaultValue != "").ToList();

                // if we have any filters with default values, we want to load this block with the page parameters already set.
                if (attribsWithDefaultValue.Any() && !this.RockPage.PageParameters().Any())
                {
                    ResetFilters();
                }
                else
                {
                    LoadFilters();
                }
            }
            else
            {
                LoadFilters();
            }

            base.OnLoad(e);

            //add postback controls
            if (Page.IsPostBack && _reloadOnSelection)
            {
                //See if hidden field has 'true' already set
                if (hfPostBack.Value.IsNullOrWhiteSpace())
                {
                    var control = Page.FindControl(Request.Form["__EVENTTARGET"]);
                    if (control != null && control.UniqueID.Contains("attribute_field_"))
                    {
                        hfPostBack.Value = "True";
                        ScriptManager.RegisterStartupScript(control, control.GetType(), "Refresh-Controls", @"console.log('Doing Postback');  __doPostBack('" + Request.Form["__EVENTTARGET"] + @"','');", true);
                    }
                }
                else //reset hidden field for next time
                {
                    hfPostBack.Value = "";
                }
            }
        }