/// <summary> /// Render a view and add it in placeholder on current page definition. /// </summary> /// <param name="placeholder"></param> /// <param name="controllerContext"></param> /// <param name="view"></param> /// <param name="viewData"></param> /// <param name="tempData"></param> /// <returns></returns> protected IView InjectViewInPlace(string placeholder, ControllerContext controllerContext, IView view, ViewDataDictionary viewData, TempDataDictionary tempData) { _logger.Info("InjectViewInPlace called on InjectViewInPlaceholderFilter", this); var pageContext = PageContext; if (placeholder != null) { var contentRendering = new ContentRendering { Id = Guid.NewGuid(), UniqueId = Guid.NewGuid(), Placeholder = placeholder, DeviceId = pageContext.Device.Id }; using (var sw = new StringWriter()) { var viewContext = new ViewContext(controllerContext, view, viewData, tempData, sw); viewContext.View.Render(viewContext, sw); contentRendering.Content = sw.ToString(); } var currentRenderings = pageContext.PageDefinition.Renderings; currentRenderings.Add(contentRendering); } return(pageContext.PageView); }
protected IView InjectViewInPlace(string placeholder, IView view, object model) { if (placeholder != null) { var contentRendering = new ContentRendering() { Id = new Guid(), UniqueId = new Guid(), Placeholder = placeholder, DeviceId = PageContext.Current.Device.Id }; var sw = new StringWriter(); if (model != null) { ViewData.Model = model; } var viewConext = new ViewContext(this.ControllerContext, view, ViewData, TempData, sw); view.Render(viewConext, sw); contentRendering.Content = sw.ToString(); var currentRenderings = PageContext.Current.PageDefinition.Renderings; currentRenderings.Add(contentRendering); } return(PageContext.Current.PageView); }
protected IView InjectViewInPlace(string placeholder, IView view, object model) { if (placeholder != null) { var contentRendering = new ContentRendering() { Id = new Guid(), UniqueId = new Guid(), Placeholder = placeholder, DeviceId = PageContext.Current.Device.Id }; var sw = new StringWriter(); if (model != null) ViewData.Model = model; var viewConext = new ViewContext(this.ControllerContext, view, ViewData, TempData, sw); view.Render(viewConext, sw); contentRendering.Content = sw.ToString(); var currentRenderings = PageContext.Current.PageDefinition.Renderings; currentRenderings.Add(contentRendering); } return PageContext.Current.PageView; }
/// <summary> /// Render a view and add it in placeholder on current page definition. /// </summary> /// <param name="placeholder"></param> /// <param name="controllerContext"></param> /// <param name="view"></param> /// <param name="viewData"></param> /// <param name="tempData"></param> /// <returns></returns> protected IView InjectViewInPlace(string placeholder, ControllerContext controllerContext, IView view, ViewDataDictionary viewData, TempDataDictionary tempData) { _logger.Info("InjectViewInPlace called on InjectViewInPlaceholderFilter", this); var pageContext = PageContext; if (placeholder != null) { controllerContext.HttpContext.Items["injectorHasRun"] = true; var contentRendering = new ContentRendering { Id = Guid.NewGuid(), UniqueId = Guid.NewGuid(), Placeholder = placeholder, DeviceId = pageContext.Device.Id }; using (var sw = new StringWriter()) { var viewContext = new ViewContext(controllerContext, view, viewData, tempData, sw); viewContext.View.Render(viewContext, sw); contentRendering.Content = sw.ToString(); } var currentRenderings = pageContext.PageDefinition.Renderings; currentRenderings.Add(contentRendering); } return pageContext.PageView; }