Esempio n. 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);
        }
Esempio n. 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();
            }
        }
Esempio n. 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];
 }
Esempio n. 4
0
 /// <summary>
 /// 转换成字符串数据
 ///
 /// </summary>
 /// <returns>字符串数据</returns>
 public override string ToString()
 {
     return(string.Format("{0}^{1}^{2}^{3}^{4}^{5}^{6}",
                          _UseNewPage, _ContentTypeKey, _DispositionType, _AttachmentFileName, _RenderControlUniqueID, PageRenderModeHelper.GetStringFromPageRenderModeCache(PageCache), _RenderArgument));
 }