/// <summary>
        ///
        /// </summary>
        /// <param name="ctr"></param>
        /// <returns></returns>
        public static ControlRenderMode GetControlRenderMode(Control ctr)
        {
            PageRenderMode    pageRenderMode = Request.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);
        }
        /// <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[PageExtension.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);

                page.AttachPageModules();

                page.ProcessRequest(HttpContext.Current);

                HttpContext.Current.Response.End();
            }
        }