private void RenderViewPage(ViewContext context, ViewPage page) { if (!String.IsNullOrEmpty(MasterPath)) { page.MasterLocation = MasterPath; } // page.ViewData = context.ViewData; page.RenderView(context); }
internal static void RenderViewAndRestoreContentType(ViewPage containerPage, ViewContext viewContext) { // We need to restore the Content-Type since Page.SetIntrinsics() will reset it. It's not possible // to work around the call to SetIntrinsics() since the control's render method requires the // containing page's Response property to be non-null, and SetIntrinsics() is the only way to set string savedContentType = viewContext.HttpContext.Response.ContentType; containerPage.RenderView(viewContext); viewContext.HttpContext.Response.ContentType = savedContentType; }
private void RenderViewPage(ViewContext context, ViewPage page) { if (!String.IsNullOrEmpty(BaseView.MasterPath)) { page.MasterLocation = BaseView.MasterPath; } page.ViewData = context.ViewData; page.PreLoad += (sender, e) => BuildUpMasterPage(page.Master); page.RenderView(context); }
private void RenderViewPage(ViewContext context, ViewPage page) { if (!string.IsNullOrEmpty(this.MasterPath)) { page.MasterLocation = this.MasterPath; } page.Init += delegate { //动态添加页面内容 this.GeneratePageContent(context, page); }; page.ViewData = context.ViewData; page.RenderView(context); }
public override void Render(ViewContext viewContext, TextWriter writer) { if (viewContext == null) { throw new ArgumentNullException("viewContext"); } controllerName = viewContext.Controller.ControllerContext.RouteData.GetRequiredString("controller"); object viewInstance = BuildManager.CreateInstanceFromVirtualPath(ViewPath, typeof(object)); if (viewInstance == null) { throw new InvalidOperationException( string.Format( "An instance of the view '{0}' could not be created.", ViewPath ) ); } ViewPage viewPage = viewInstance as ViewPage; if (viewPage != null) { if (!string.IsNullOrEmpty(MasterPath) && !string.IsNullOrEmpty(viewPage.MasterLocation)) { viewPage.MasterLocation = MasterPath; } viewPage.ViewData = viewContext.ViewData; viewPage.PreInit += viewPage_PreInit; viewPage.RenderView(viewContext); return; } base.Render(viewContext, writer); }