Example #1
0
        ///// <summary>
        ///// Handles a callback event
        ///// </summary>
        ///// <returns></returns>
        //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Method has a side-effect")]
        //protected virtual string GetCallbackResult()
        //{
        //    string argument = _callbackArgument;
        //    _callbackArgument = null;
        //    return ScriptObjectBuilder.ExecuteCallbackMethod(this, argument);
        //}

        ///// <summary>
        ///// Raises a callback event
        ///// </summary>
        ///// <param name="eventArgument"></param>
        //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate", Justification = "Maintaining consistency with ICallbackEventHandler")]
        //protected virtual void RaiseCallbackEvent(string eventArgument)
        //{
        //    _callbackArgument = eventArgument;
        //}

        //protected virtual void RaisePostBackEvent(string eventArgument)
        //{
        //}

        /// <summary>
        /// Restores view-state information from a previous request that was saved with the SaveViewState method.
        /// 并在LoadViewState之前缓存ViewState中所有IStateManager类型项
        /// 以及在LoadViewState之后从缓存中恢复将ViewState中ViewSateItemInternal类型项恢复成IStateManager类型项
        /// </summary>
        /// <param name="savedState">An object that represents the control state to restore.</param>
        protected override void LoadViewState(object savedState)
        {
            StateBag backState = WebControlUtility.PreLoadViewState(ViewState);

            base.LoadViewState(savedState);
            WebControlUtility.AfterLoadViewState(ViewState, backState);
        }
Example #2
0
        /// <summary>
        /// Saves any state that was modified after the TrackViewState method was invoked
        /// 并在SaveViewState之前,将ViewState中所有IStateManager类型项转换为可序列化的ViewSateItemInternal类型项
        /// 以及在SaveViewState之后,将ViewState中所有ViewSateItemInternal类型项恢复成IStateManager类型项
        /// </summary>
        /// <returns></returns>
        protected override object SaveViewState()
        {
            WebControlUtility.PreSaveViewState(ViewState);
            object o = base.SaveViewState();

            WebControlUtility.AfterSavedViewState(ViewState);

            return(o);
        }
Example #3
0
        /// <summary>
        /// 判断是否只是输出本控件,如果是则进行只输出本控件处理,否则进行正常的控件输出
        /// </summary>
        /// <param name="writer">接收控件内容的 HtmlTextWriter 对象。</param>
        public override void RenderControl(HtmlTextWriter writer)
        {
            if (this.RenderMode.OnlyRenderSelf)
            {
                StringBuilder strB = new StringBuilder();
                StringWriter  sw   = new StringWriter(strB);
                using (HtmlTextWriter baseWriter = new HtmlTextWriter(sw))
                {
                    base.RenderControl(baseWriter);
                }

                WebControlUtility.RenderControlOnlySelf(this, strB.ToString(), this.RenderMode);
            }
            else
            {
                base.RenderControl(writer);
            }
        }
Example #4
0
 /// <summary>
 /// 设置某属性的值
 /// </summary>
 /// <typeparam name="V">属性类型</typeparam>
 /// <param name="propertyName">属性名称</param>
 /// <param name="value">属性值</param>
 protected void SetPropertyValue <V>(string propertyName, V value)
 {
     WebControlUtility.SetViewStateValue <V>(ViewState, propertyName, value);
 }
Example #5
0
 /// <summary>
 /// 从ViewState中获取某属性值,如果为空则返回默认值nullValue
 /// </summary>
 /// <typeparam name="V">属性类型</typeparam>
 /// <param name="propertyName">属性名称</param>
 /// <param name="nullValue">默认值</param>
 /// <returns>属性值</returns>
 protected V GetPropertyValue <V>(string propertyName, V nullValue)
 {
     return(WebControlUtility.GetViewStateValue <V>(ViewState, propertyName, nullValue));
 }
Example #6
0
 /// <summary>
 /// Causes the control to track changes to its view state so they can be stored in the object's ViewState property
 /// 并将ViewState中所有IStateManager类型项标记为TrackViewState
 /// </summary>
 protected override void TrackViewState()
 {
     base.TrackViewState();
     WebControlUtility.TrackViewState(ViewState);
 }