本文整理汇总了C#中System.Web.UI.WebControls.Panel.ToScript方法的典型用法代码示例。如果您正苦于以下问题:C# Panel.ToScript方法的具体用法?C# Panel.ToScript怎么用?C# Panel.ToScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.Panel
的用法示例。
在下文中一共展示了Panel.ToScript方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
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;
}