public virtual string Render(ControllerContext context, string viewName, ViewDataDictionary viewData, object model, TempDataDictionary tempData, IDMode idMode, string controlId) { if (context == null) { throw new ArgumentNullException("context"); } if (String.IsNullOrEmpty(viewName)) { viewName = context.RouteData.GetRequiredString("action"); } //string path = PartialViewResult.FindView(context, viewName); string id = controlId ?? "ID_" + Guid.NewGuid().ToString().Replace("-", ""); string ct = "ID_" + Guid.NewGuid().ToString().Replace("-", ""); ViewDataDictionary newViewData = null; if (model == null) { if (viewData == null) { newViewData = new ViewDataDictionary(); } else { newViewData = new ViewDataDictionary(viewData); } } else { if (viewData == null) { newViewData = new ViewDataDictionary(model); } else { newViewData = new ViewDataDictionary(viewData) { Model = model }; } } ViewEngineResult result = ViewEngines.Engines.FindPartialView(context, viewName); IView view = result.View; string path = ((WebFormView)view).ViewPath; ViewContext viewContext = new ViewContext(context, view, newViewData, tempData ?? new TempDataDictionary(), context.HttpContext.Response.Output); PartialViewPage pageHolder = new PartialViewPage { ViewData = newViewData, ViewContext = viewContext }; var curRM = HttpContext.Current.Items[typeof(ResourceManager)]; HttpContext.Current.Items[typeof(ResourceManager)] = null; object oldPageRM = null; if (context.HttpContext.CurrentHandler is Page) { oldPageRM = ((Page)HttpContext.Current.CurrentHandler).Items[typeof(ResourceManager)]; ((Page)HttpContext.Current.CurrentHandler).Items[typeof(ResourceManager)] = null; } ResourceManager rm = new ResourceManager(); rm.RenderScripts = ResourceLocationType.None; rm.RenderStyles = ResourceLocationType.None; rm.IDMode = idMode; pageHolder.Controls.Add(rm); Panel p = new Panel { ID = id, IDMode = idMode, Border = false, Header = false }; pageHolder.Controls.Add(p); ViewUserControl uc = (ViewUserControl)pageHolder.LoadControl(path); uc.ID = id + "_UC"; uc.ViewData = newViewData; p.ContentControls.Add(uc); pageHolder.InitHelpers(); string script = string.Format("<div id=\"{0}\"></div><script type=\"text/javascript\">Ext.onReady(function(){{{1}}});</script>", ct, p.ToScript(RenderMode.RenderTo, ct, true)); IDisposable disposable = view as IDisposable; if (disposable != null) { disposable.Dispose(); } HttpContext.Current.Items[typeof(ResourceManager)] = curRM; if (context.HttpContext.CurrentHandler is Page) { ((Page)HttpContext.Current.CurrentHandler).Items[typeof(ResourceManager)] = oldPageRM; } return script; }