예제 #1
0
        protected override Object LoadPageStateFromPersistenceMedium()
        {
            Object state = null;

            String clientViewStateString = _requestValueCollection[ViewStateID];

            if (clientViewStateString != null)
            {
                _privateViewState =
                    StateFormatter.Deserialize(clientViewStateString) as Hashtable;
                if (_privateViewState != null)
                {
                    String[] arr = _privateViewState[PageClientViewStateKey] as String[];
                    if (arr != null)
                    {
                        _activeFormID = arr[0];

                        String id = arr[1];
                        if (id != null)
                        {
                            _sessionViewState.Load(this, id);
                            state = _sessionViewState.ViewState;
                            if (state == null)
                            {
                                OnViewStateExpire(EventArgs.Empty);
                            }
                            else
                            {
                                Object[] arrState = state as Object[];
                                if (arrState != null)
                                {
                                    _privateViewState = (Hashtable)arrState[1];
                                    state             = arrState[0];
                                }
                            }
                        }
                    }
                    _privateViewState.Remove(PageClientViewStateKey);

                    // If the page had no view state, but had controls requiring postback,
                    // this information was saved in client view state.

                    Object controlsRequiringPostBack =
                        _privateViewState[_controlsRequiringPostBackKey];
                    if (controlsRequiringPostBack != null)
                    {
                        state = new Triplet(GetTypeHashCode().ToString(),
                                            null,
                                            controlsRequiringPostBack);
                        _privateViewState.Remove(_controlsRequiringPostBackKey);
                    }

                    // Apply whatever private view state can be applied now.

                    foreach (DictionaryEntry entry in _privateViewState)
                    {
                        if (entry.Value != null)
                        {
                            MobileControl ctl = FindControl((String)entry.Key) as MobileControl;
                            if (ctl != null)
                            {
                                ctl.LoadPrivateViewStateInternal(entry.Value);
                            }
                        }
                    }
                }
            }

            _privateViewStateLoaded = true;

            if (state == null)
            {
                // Give framework back an empty page view state
                state = new Triplet(GetTypeHashCode().ToString(), null, null);
            }
            return(state);
        }