Пример #1
0
        // Same as LoadRecursive, but has an async point immediately after the call to this.OnLoad.
        internal async Task LoadRecursiveAsync(Page page) {
            // Only make the actual call if it hasn't already happened (ASURT 111303)
            if (_controlState < ControlState.Loaded) {
                using (page.Context.SyncContext.AllowVoidAsyncOperationsBlock()) {
                    if (AdapterInternal != null) {
                        AdapterInternal.OnLoad(EventArgs.Empty);
                    }
                    else {
                        OnLoad(EventArgs.Empty);
                    }
                    await page.GetWaitForPreviousStepCompletionAwaitable();
                }
            }

            // Call Load on all our children
            if (_controls != null) {
                string oldmsg = _controls.SetCollectionReadOnly(SR.Parent_collections_readonly);

                int controlCount = _controls.Count;
                for (int i = 0; i < controlCount; i++) {
                    _controls[i].LoadRecursive();
                }

                _controls.SetCollectionReadOnly(oldmsg);
            }

            if (_controlState < ControlState.Loaded)
                _controlState = ControlState.Loaded;
        }
Пример #2
0
        // Same as PreRenderRecursive, but has an async point after the call to this.OnPreRender.
        internal async Task PreRenderRecursiveInternalAsync(Page page) {
            // Call Visible property and cache value in !flags[invisible] to allow Visible to be overridden.
            // This avoids unnecessary virtual property calls in SaveViewState and Render.
            bool visible = Visible;
            if (!visible) {
                flags.Set(invisible);
            }
            else {
                flags.Clear(invisible);
                EnsureChildControls();

                using (page.Context.SyncContext.AllowVoidAsyncOperationsBlock()) {
                    if (AdapterInternal != null) {
                        AdapterInternal.OnPreRender(EventArgs.Empty);
                    }
                    else {
                        OnPreRender(EventArgs.Empty);
                    }
                    await page.GetWaitForPreviousStepCompletionAwaitable();
                }

                if (_controls != null) {
                    string oldmsg = _controls.SetCollectionReadOnly(SR.Parent_collections_readonly);

                    int controlCount = _controls.Count;
                    for (int i = 0; i < controlCount; i++) {
                        _controls[i].PreRenderRecursiveInternal();
                    }
                    _controls.SetCollectionReadOnly(oldmsg);
                }
            }
            _controlState = ControlState.PreRendered;
        }
Пример #3
0
        // TAP version of InitRecursive
        // !! IMPORTANT !!
        // If you make changes to this method, also change InitRecursive.
        internal async Task InitRecursiveAsync(Control namingContainer, Page page) {
            ResolveAdapter();
            if (_controls != null) {
                if (flags[isNamingContainer]) {
                    namingContainer = this;
                }
                string oldmsg = _controls.SetCollectionReadOnly(SR.Parent_collections_readonly);

                int controlCount = _controls.Count;
                for (int i = 0; i < controlCount; i++) {
                    Control control = _controls[i];

                    // Propagate the page and namingContainer
                    control.UpdateNamingContainer(namingContainer);

                    if ((control._id == null) && (namingContainer != null) && !control.flags[idNotRequired]) {
                        control.GenerateAutomaticID();
                    }
                    control._page = Page;

                    control.InitRecursive(namingContainer);
                }
                _controls.SetCollectionReadOnly(oldmsg);

            }

            // Only make the actual call if it hasn't already happened (ASURT 111303)
            if (_controlState < ControlState.Initialized) {
                _controlState = ControlState.ChildrenInitialized; // framework also initialized

                if ((Page != null) && !DesignMode) {
                    if (Page.ContainsTheme && EnableTheming) {
                        ApplySkin(Page);
                    }
                }

                using (page.Context.SyncContext.AllowVoidAsyncOperationsBlock()) {
                    if (AdapterInternal != null) {
                        AdapterInternal.OnInit(EventArgs.Empty);
                    }
                    else {
                        OnInit(EventArgs.Empty);
                    }
                    await page.GetWaitForPreviousStepCompletionAwaitable();
                }

                _controlState = ControlState.Initialized;
            }

            // track all subsequent state changes
            TrackViewState();

#if DEBUG
            ControlInvariant();
#endif
        }