Exemple #1
0
    protected override void OnInit(EventArgs e)
    {
        if (StopProcessing)
        {
            // No actions if processing is stopped
        }
        else
        {
            SetHeaderControls(paneTabs);

            if (PortalContext.ViewMode.IsDesign(true))
            {
                paneContent.RenderAs = HtmlTextWriterTag.Div;
                paneContent.Size     = "0";
            }

            SiteSelector.DropDownSingleSelect.AutoPostBack = true;
            PlaceHolder panel = paneTabs.FindControl("pnlSiteContainer") as PlaceHolder;
            if (panel != null)
            {
                if (DisplaySiteSelector)
                {
                    SiteSelector.AllowAll    = AllowAll;
                    SiteSelector.AllowEmpty  = AllowEmpty;
                    SiteSelector.AllowGlobal = AllowGlobal;

                    if (!RequestHelper.IsPostBack())
                    {
                        int siteId = ValidationHelper.GetInteger(UIContext["SiteID"], 0);
                        if (siteId != 0)
                        {
                            SiteSelector.Value = siteId;
                        }

                        // Reload for first time selection
                        SiteSelector.Reload(false);
                    }

                    // Register event
                    UIContext.OnGetValue += Current_OnGetValue;
                }
                else
                {
                    panel.Visible = false;
                    SiteSelector.StopProcessing = true;
                }
            }
        }

        base.OnInit(e);
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnContentLoaded();

        // Set visibility
        if (SelectorType == SiteSelectorTypeEnum.SiteOrGlobal)
        {
            SiteSelector.StopProcessing = true;
            SiteOrGlobal.Visible        = true;

            ScriptManager.GetCurrent(Page).RegisterPostBackControl(SiteOrGlobal.Selector);

            if (!RequestHelper.IsPostBack())
            {
                siteId = ValidationHelper.GetInteger(UIContext["SiteID"], 0);

                if (siteId != 0)
                {
                    SiteOrGlobal.Reload();
                    SiteOrGlobal.Value = siteId;
                }
            }
        }
        else
        {
            ScriptManager.GetCurrent(Page).RegisterPostBackControl(SiteSelector);

            SiteSelector.Visible        = true;
            SiteOrGlobal.StopProcessing = true;

            SiteSelector.DropDownSingleSelect.AutoPostBack = true;

            SiteSelector.AllowGlobal = AllowGlobal;
            SiteSelector.AllowAll    = AllowAll;

            if (!RequestHelper.IsPostBack())
            {
                siteId = ValidationHelper.GetInteger(UIContext["SiteID"], 0);

                if (siteId != 0)
                {
                    SiteSelector.Value = siteId;
                }
                else
                {
                    // If site id is not set, select 'all' (if present). Otherwise select current site.
                    SiteSelector.Value = (AllowAll) ? UniSelector.US_ALL_RECORDS.ToString() : SiteContext.CurrentSiteID.ToString();
                }

                // Reload for first time selection
                SiteSelector.Reload(false);
            }
            else if (GetValue("Visible").ToBoolean(false))
            {
                UIContext["SiteID"] = SiteSelector.Value;
            }
        }

        // Register event
        UIContext.OnGetValue += Current_OnGetValue;

        base.OnInit(e);
    }