示例#1
0
        protected static FormBase GetCurrentPage()
        {
            if (System.Web.HttpContext.Current == null || System.Web.HttpContext.Current.Handler == null || !(System.Web.HttpContext.Current.Handler is FormBase))
            {
                throw new Exception("Esse método de busca por Ajax somente deve ser utilizado em páginas que implementem a classe \"FormBase\".");
            }

            FormBase page = (FormBase)System.Web.HttpContext.Current.Handler;

            System.Reflection.MethodInfo setIntrinsics = typeof(System.Web.UI.Page).GetMethod("SetIntrinsics", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic, null, new Type[] { typeof(System.Web.HttpContext) }, null);
            setIntrinsics.Invoke(page, new object[] { System.Web.HttpContext.Current });
            page.FrameworkInitialize();
            System.Reflection.MethodInfo performePreInit = typeof(System.Web.UI.Page).GetMethod("PerformPreInit", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
            performePreInit.Invoke(page, null);

            return(page);
        }
示例#2
0
        public static string PopularGridAjax()
        {
            try
            {
                if (System.Web.HttpContext.Current == null || System.Web.HttpContext.Current.Handler == null || !(System.Web.HttpContext.Current.Handler is IPaginaPesquisa))
                {
                    throw new Exception("Esse método de busca por Ajax somente deve ser utilizado em páginas que implementem a interface \"IPaginaPesquisa\".");
                }

                FormBase        page           = GetCurrentPage();
                IPaginaPesquisa paginaPesquisa = page as IPaginaPesquisa;

                page.IgnoreVerifyForm = true;
                return(RenderControl(paginaPesquisa.PopularGrid()));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }