Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ctr"></param>
        /// <returns></returns>
        public static ControlRenderMode GetControlRenderMode(Control ctr)
        {
            PageRenderMode    pageRenderMode = WebUtility.GetRequestPageRenderMode();
            ControlRenderMode renderMode     = new ControlRenderMode(pageRenderMode);

            PageRenderModePageCache currentPageCache = PageRenderModeHelper.GetPageRenderModeCache(ctr.Page);
            PageRenderModePageCache requestPageCache = renderMode.PageCache;

            int    currentPageLevel    = GetPageLevel(currentPageCache);
            string currentPageUniqueID = GetPageUniqueID(currentPageCache);
            int    requestPageLevel    = GetPageLevel(requestPageCache);
            string requestPageUniqueID = GetPageUniqueID(requestPageCache);

            if (requestPageLevel == currentPageLevel)
            {
                if (ctr.UniqueID == pageRenderMode.RenderControlUniqueID)
                {
                    renderMode.OnlyRenderSelf = true;
                }
            }
            else if (requestPageLevel > currentPageLevel)
            {
                string id = requestPageUniqueID.Split(',')[currentPageLevel];

                if (ctr.UniqueID == id)
                {
                    renderMode.OnlyRenderSelf = true;
                }
            }

            return(renderMode);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ctr"></param>
        /// <param name="renderMode"></param>
        public static void CheckOnlyRenderSelf(Control ctr, ControlRenderMode renderMode)
        {
            if (renderMode.OnlyRenderSelf && renderMode.UseNewPage && ctr.Page.Items[WebUtility.PageRenderControlItemKey] != ctr)
            {
                Page currentPage = ctr.Page;
                ctr.Parent.Controls.GetType().GetMethod("SetCollectionReadOnly", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(ctr.Parent.Controls, new object[1] {
                    null
                });
                Page page = new Page();
                PageRenderModePageCache currentPageCache = PageRenderModeHelper.GetPageRenderModeCache(currentPage);
                PageRenderModePageCache pageCache        = PageRenderModeHelper.GetPageRenderModeCache(page);
                SetPageLevel(pageCache, GetPageLevel(currentPageCache) + 1);
                string currentPageUniqueID = GetPageUniqueID(currentPageCache);
                if (currentPageUniqueID != string.Empty)
                {
                    currentPageUniqueID += ",";
                }
                SetPageUniqueID(pageCache, string.Format("{0}{1}", GetPageUniqueID(currentPageCache), ctr.UniqueID));
                page.AppRelativeVirtualPath = ctr.Page.AppRelativeVirtualPath;
                page.EnableEventValidation  = false;

                InitNewPageContent(page, ctr);

                WebUtility.AttachPageModules(page);

                page.ProcessRequest(HttpContext.Current);

                HttpContext.Current.Response.End();
            }
        }
Пример #3
0
 private void Load(string strData)
 {
     string[] strArray = strData.Split('^');
     _UseNewPage            = bool.Parse(strArray[0]);
     _ContentTypeKey        = strArray[1];
     _DispositionType       = (ResponseDispositionType)Enum.Parse(typeof(ResponseDispositionType), strArray[2], true);
     _AttachmentFileName    = strArray[3];
     _RenderControlUniqueID = strArray[4];
     _PageCache             = PageRenderModeHelper.GetPageRenderModeCacheFromString(strArray[5]);
     _RenderArgument        = strArray[6];
 }
Пример #4
0
        public static PageRenderModePageCache GetPageRenderModeCache(Page page)
        {
            PageRenderModePageCache cache = (PageRenderModePageCache)page.Items[_S_PageRenderModeCacheKey];

            if (cache == null)
            {
                cache = new PageRenderModePageCache();
                page.Items[_S_PageRenderModeCacheKey] = cache;
            }

            return(cache);
        }
Пример #5
0
 /// <summary>
 /// 通过页面输出状态,加载控件的输出状态
 /// </summary>
 /// <param name="pageRenderMode">页面输出模式</param>
 /// <remarks>通过页面输出状态,加载控件的输出状态</remarks>
 public void LoadFromPageRenderMode(PageRenderMode pageRenderMode)
 {
     //if (!string.IsNullOrEmpty(controlUniqueID) && controlUniqueID == pageRenderMode.RenderControlUniqueID)
     //{
     //    this._OnlyRenderSelf = true;
     //}
     this._UseNewPage         = pageRenderMode.UseNewPage;
     this._ContentTypeKey     = pageRenderMode.ContentTypeKey;
     this._DispositionType    = pageRenderMode.DispositionType;
     this._AttachmentFileName = pageRenderMode.AttachmentFileName;
     this._PageCache          = pageRenderMode.PageCache;
     this._RenderArgument     = pageRenderMode.RenderArgument;
 }
Пример #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cache"></param>
 /// <param name="level"></param>
 public static void SetPageLevel(PageRenderModePageCache cache, int level)
 {
     cache[_S_PageLevelKey] = level;
 }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cache"></param>
        /// <returns></returns>
        public static int GetPageLevel(PageRenderModePageCache cache)
        {
            int level = cache.GetValue <int>(_S_PageLevelKey, 0);

            return(level);
        }
Пример #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cache"></param>
 /// <param name="id"></param>
 public static void SetPageUniqueID(PageRenderModePageCache cache, string id)
 {
     cache[_S_PageUniqueIDKey] = id;
 }
Пример #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cache"></param>
        /// <returns></returns>
        public static string GetPageUniqueID(PageRenderModePageCache cache)
        {
            string id = cache.GetValue <string>(_S_PageUniqueIDKey, string.Empty);

            return(id == null ? string.Empty : (string)id);
        }
Пример #10
0
 public static string GetStringFromPageRenderModeCache(PageRenderModePageCache cache)
 {
     return(Json.JsonHelper.Serialize(cache));
 }