public override void RegisterScripts(ResourceManager scriptManager) { scriptManager.RegisterClientScriptInclude("TreeCssInitializer", WebResourceUtility.GetUrl(GetType(), "Zeus.Admin.Plugins.Tree.Resources.TreeCssInitializer.js")); // Call tree modification plugins. foreach (ITreePlugin treePlugin in Context.Current.ResolveAll<ITreePlugin>()) { string[] requiredScripts = treePlugin.RequiredScripts; if (requiredScripts != null) foreach (string requiredScript in requiredScripts) scriptManager.RegisterClientScriptInclude(treePlugin.GetType().FullName, requiredScript); } }
public virtual void RegisterScripts(ResourceManager scriptManager) { string[] requiredScripts = RequiredScripts; if (requiredScripts != null) foreach (string requiredScript in requiredScripts) scriptManager.RegisterClientScriptInclude(GetType().FullName, requiredScript); }
public virtual void RegisterStyles(ResourceManager scriptManager) { string[] requiredStyles = RequiredStyles; if (requiredStyles != null) foreach (string requiredStyle in requiredStyles) scriptManager.RegisterClientStyleInclude(GetType().FullName, requiredStyle); }
protected void ChangeTheme(ResourceManager getInstance) { if (Session["theme"]!=null) { switch (Session["theme"].ToString()) { case "Aria": getInstance.Theme = Ext.Net.Theme.Aria; break; case "Neptune": getInstance.Theme = Ext.Net.Theme.Neptune; break; case "Gray": getInstance.Theme = Ext.Net.Theme.Gray; break; case "Default": getInstance.Theme = Ext.Net.Theme.Default; break; case "Crisp": getInstance.Theme = Ext.Net.Theme.Crisp; break; default: getInstance.Theme = Ext.Net.Theme.Crisp; break; } } else { getInstance.Theme = Ext.Net.Theme.Crisp; } }
public override void RegisterScripts(ResourceManager scriptManager) { // Render action plugin scripts. scriptManager.RegisterClientScriptInclude("ActionPlugin", WebResourceUtility.GetUrl(typeof(ContextMenuMainInterfacePlugin), "Zeus.Admin.Plugins.ContextMenu.Resources.Ext.ux.zeus.ContextMenuPlugin.js")); foreach (IContextMenuPlugin plugin in Context.Current.ResolveAll<IContextMenuPlugin>()) { string[] requiredScripts = plugin.RequiredScripts; if (requiredScripts != null) foreach (string requiredScript in requiredScripts) scriptManager.RegisterClientScriptInclude(plugin.GetType().FullName, requiredScript); } }
protected override void RegisterControlResourcesInManager(ResourceManager manager, BaseControl ctrl) { }
/// <summary> /// /// </summary> /// <param name="control"></param> protected override void CheckResources(BaseControl control, ResourceManager manager) { }
public virtual string Build(bool selfRendering, bool forceResources) { this.ForceResources = forceResources; if (this.script == null) { Page pageHolder = null; this.Control.TopDynamicControl = true; this.Control.ForceIdRendering = true; if (selfRendering && this.Control.Page == null) { pageHolder = new SelfRenderingPage(); ResourceManager rm = new ResourceManager(); rm.RenderScripts = ResourceLocationType.None; rm.RenderStyles = ResourceLocationType.None; rm.IDMode = IDMode.Client; rm.IsDynamic = true; pageHolder.Controls.Add(rm); pageHolder.Controls.Add(this.Control); } else if (selfRendering && this.Control.Page is ISelfRenderingPage) { pageHolder = this.Control.Page; ResourceManager newMgr = Ext.Net.Utilities.ControlUtils.FindControl<ResourceManager>(pageHolder); if (newMgr != null) { newMgr.IsDynamic = true; } } StringBuilder sb = new StringBuilder(); this.Control.ContentUpdated = this.Control.HasContent(); ContainerBase container = this.Control as ContainerBase; if (container != null && container.Items.Count > 0) { sb.AppendFormat("{0}.removeAll();", this.Control.ClientID); } List<XControl> childControls = this.FindControls(this.Control, selfRendering, sb, null); foreach (XControl c in childControls) { if (c.Visible) { c.DeferInitScriptGeneration = selfRendering; if (c.AutoDataBind) { c.DataBind(); } } } if (selfRendering) { this.RegisterHtml(sb, pageHolder); foreach (XControl c in childControls) { c.DeferInitScriptGeneration = false; } List<XControl> newChildControls = this.FindControls(this.Control, false, sb, null); newChildControls.Insert(0, this.Control); foreach (XControl c in newChildControls) { if (!childControls.Contains(c) && (c.Visible || Object.ReferenceEquals(c, this.Control))) { if (c.AutoDataBind) { c.DataBind(); } } } childControls = newChildControls; } foreach (XControl c in childControls) { if (c.Visible) { c.OnClientInit(true); c.RegisterBeforeAfterScript(); } } foreach (XControl c in childControls) { if (c.Visible) { string initScript = c.BuildInitScript(); if (!string.IsNullOrEmpty(initScript)) { if (this.layoutItems.Contains(c)) { this.ScriptClientInitBag.Add(c.ClientInitID, this.Control.ClientID.ConcatWith(".add(", initScript, ");")); } else { this.ScriptClientInitBag.Add(c.ClientInitID, initScript); } } c.AlreadyRendered = true; foreach (KeyValuePair<long, string> proxyScript in c.ProxyScripts) { if (proxyScript.Value.IsNotEmpty()) { this.ScriptOnReadyBag.Add(proxyScript.Key, proxyScript.Value); } } } } if (this.ScriptClientInitBag.Count > 0) { foreach (KeyValuePair<string, string> item in this.ScriptClientInitBag) { sb.Append(this.Combine(item.Key)); } } foreach (KeyValuePair<long, string> script in this.ScriptOnReadyBag) { sb.Append(script.Value); } //if (selfRendering) //{ // this.RegisterHtml(sb, pageHolder); //} if (container != null && container.Items.Count > 0) { sb.AppendFormat("{0}.doLayout();", this.Control.ClientID); } this.script = this.RegisterResources(sb.ToString()); } return this.script; }
public virtual string Build(RenderMode mode, string element, int? index, bool selfRendering, bool forceResources, string method, bool forceLazy, bool clearContainer) { this.ForceResources = forceResources; if (this.script == null) { AbstractComponent cmp = this.Control as AbstractComponent; bool isLazy = this.Control.IsLazy; if (mode == RenderMode.Auto) { mode = isLazy ? RenderMode.AddTo : RenderMode.RenderTo; } switch (mode) { case RenderMode.RenderTo: if (cmp != null) { if (string.IsNullOrEmpty(element)) { element = TokenUtils.RawWrap("Ext.net.ResourceMgr.getRenderTarget()"); } if (this.Control.IsLazy) { throw new Exception("Lazy control cannot be rendered with RenderTo mode."); } cmp.RenderTo = element; } break; case RenderMode.AddTo: case RenderMode.Replace: case RenderMode.InsertTo: if (cmp == null) { throw new Exception("AddTo mode can be applied to only a AbstractComponent."); } if (string.IsNullOrEmpty(element)) { if (isLazy) { element = this.Control.ParentComponent.ClientID; } else { throw new Exception("You must specify an Element for the AddTo mode."); } } if (mode == RenderMode.InsertTo && index == null) { throw new Exception("You have to provide the index for the InsertTo mode."); } cmp.PreventRenderTo = true; break; } Page pageHolder = null; this.Control.IsDynamicLazy = isLazy || (mode == RenderMode.AddTo || mode == RenderMode.InsertTo || mode == RenderMode.Replace); this.Control.TopDynamicControl = true; //this.Control.ForceIdRendering = true; this.Control.ForceLazy = forceLazy || this.Control.IsDynamicLazy; this.ResourceManager = Ext.Net.ResourceManager.GetInstance(); if (selfRendering && this.Control.Page == null) { pageHolder = new SelfRenderingPage(); ResourceManager newMgr = new ResourceManager(true); newMgr.RenderScripts = ResourceLocationType.None; newMgr.RenderStyles = ResourceLocationType.None; newMgr.IDMode = IDMode.Explicit; newMgr.IsDynamic = true; pageHolder.Controls.Add(newMgr); if (this.ResourceManager == null) { this.ResourceManager = newMgr; } pageHolder.Controls.Add(this.Control); } else if (selfRendering && this.Control.Page is ISelfRenderingPage) { pageHolder = this.Control.Page; ResourceManager newMgr = Ext.Net.Utilities.ControlUtils.FindControl<ResourceManager>(pageHolder); if (this.ResourceManager == null) { this.ResourceManager = newMgr; } if (newMgr != null) { newMgr.IsDynamic = true; } } StringBuilder sb = new StringBuilder(); if (this.Control.ClientID.IsNotEmpty() && !this.Control.IsGeneratedID) { sb.AppendFormat("Ext.net.ResourceMgr.destroyCmp(\"{0}\");", this.Control.ClientID); } if (clearContainer) { if (mode == RenderMode.AddTo || mode == RenderMode.InsertTo) { string elementGet = element.Contains(".") ? element : "Ext.getCmp({0})".FormatWith(JSON.Serialize(element)); sb.AppendFormat("{0}.removeAll();", elementGet); } else if(mode != RenderMode.Replace) { sb.AppendFormat("Ext.net.getEl(\"{0}\").update();", element); } } List<BaseControl> childControls = this.FindControls(this.Control, selfRendering, sb, null, null); childControls.Insert(0, this.Control); if (selfRendering && pageHolder != null) { pageHolder.Items["Ext.Net.DeferInitScriptGeneration"] = new object(); } foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { if (c.AutoDataBind) { c.DataBind(); } } } if (selfRendering) { this.RegisterHtml(sb, pageHolder); if (pageHolder != null) { pageHolder.Items["Ext.Net.DeferInitScriptGeneration"] = null; } List<BaseControl> newChildControls = this.FindControls(this.Control, false, sb, null, null); newChildControls.Insert(0, this.Control); foreach (BaseControl c in newChildControls) { if (!childControls.Contains(c) && (c.Visible || Object.ReferenceEquals(c, this.Control))) { if (c.AutoDataBind) { c.DataBind(); } } } childControls = newChildControls; } foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { c.OnClientInit(true); c.RegisterBeforeAfterScript(); } } string methodTemplate = string.Concat(".",method ?? "add","("); if (mode == RenderMode.InsertTo) { methodTemplate = string.Concat(".", method ?? "insert", "(", index.Value, ","); } foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { if (Object.ReferenceEquals(c, this.Control) && (this.Control.IsLazy || this.Control.ForceLazy)) { this.ScriptClientInitBag.Add(c.ClientInitID + "_BeforeScript", c.BeforeScript); string initScript = c.BuildInitScript(); string topScript = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.ItemTag), new Dictionary<string, string>{ {"ref", "top_dynamic_control"}, {"index", ResourceManager.ScriptOrderNumber.ToString()} }, initScript); this.ScriptClientInitBag.Add(c.ClientInitID, topScript); this.ScriptClientInitBag.Add(c.ClientInitID + "_AfterScript", c.AfterScript); } else { string tokenValue = ((c is LazyObservable && c.IsIdRequired) ? "window.{0}=".FormatWith(c.ClientID) : "") + c.BuildInitScript(); string script = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.ItemTag), new Dictionary<string, string>{ {"ref", c.IsLazy ? c.ClientInitID : "init_script"}, {"index", ResourceManager.ScriptOrderNumber.ToString()} }, tokenValue); this.ScriptClientInitBag.Add(c.ClientInitID, script); } c.AlreadyRendered = true; foreach (KeyValuePair<long, string> proxyScript in c.ProxyScripts) { if (proxyScript.Value.IsNotEmpty()) { this.ScriptOnReadyBag.Add(proxyScript.Key, proxyScript.Value); } } } } if (this.ScriptClientInitBag.Count > 0) { foreach (KeyValuePair<string, string> item in this.ScriptClientInitBag) { sb.Append(this.ScriptClientInitBag[item.Key]); } } sb.Append(Transformer.NET.Net.CreateToken(typeof(Transformer.NET.AnchorTag), new Dictionary<string, string>{ {"id", "init_script"} })); string topAnchor = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.AnchorTag), new Dictionary<string, string>{ {"id", "top_dynamic_control"} }); if (mode == RenderMode.AddTo || mode == RenderMode.InsertTo) { string elementGet = element.Contains(".") ? element : "Ext.getCmp({0})".FormatWith(JSON.Serialize(element)); sb.Append(elementGet.ConcatWith(methodTemplate, topAnchor, ");")); } else if (mode == RenderMode.Replace) { sb.Append("Ext.net._renderTo(arguments[0],".ConcatWith(topAnchor, ");")); } foreach (KeyValuePair<long, string> script in this.ScriptOnReadyBag) { sb.Append(script.Value); } if (mode == RenderMode.Replace) { string elementGet = element.Contains(".") ? element : "Ext.getCmp({0})".FormatWith(JSON.Serialize(element)); sb.Insert(0, elementGet + ".replace(function(){"); sb.Append("});"); } this.script = this.RegisterResources(sb.ToString()); } this.Control.ForceLazy = false; return Transformer.NET.Html.HtmlTransformer.Transform(this.script); }
public virtual string Build(RenderMode mode, string element, int?index, bool selfRendering, bool forceResources, string method, bool forceLazy, bool clearContainer) { this.ForceResources = forceResources; if (this.script == null) { AbstractComponent cmp = this.Control as AbstractComponent; bool isLazy = this.Control.IsLazy; if (mode == RenderMode.Auto) { mode = isLazy ? RenderMode.AddTo : RenderMode.RenderTo; } switch (mode) { case RenderMode.RenderTo: if (cmp != null) { if (string.IsNullOrEmpty(element)) { element = TokenUtils.RawWrap("Ext.net.ResourceMgr.getRenderTarget()"); } if (this.Control.IsLazy) { throw new Exception("Lazy control cannot be rendered with RenderTo mode."); } cmp.RenderTo = element; } break; case RenderMode.AddTo: case RenderMode.Replace: case RenderMode.InsertTo: if (cmp == null) { throw new Exception("AddTo mode can be applied to only a AbstractComponent."); } if (string.IsNullOrEmpty(element)) { if (isLazy) { element = this.Control.ParentComponent.ClientID; } else { throw new Exception("You must specify an Element for the AddTo mode."); } } if (mode == RenderMode.InsertTo && index == null) { throw new Exception("You have to provide the index for the InsertTo mode."); } cmp.PreventRenderTo = true; break; } Page pageHolder = null; this.Control.IsDynamicLazy = isLazy || (mode == RenderMode.AddTo || mode == RenderMode.InsertTo || mode == RenderMode.Replace); this.Control.TopDynamicControl = true; //this.Control.ForceIdRendering = true; this.Control.ForceLazy = forceLazy || this.Control.IsDynamicLazy; this.ResourceManager = Ext.Net.ResourceManager.GetInstance(); if (selfRendering && this.Control.Page == null) { pageHolder = new SelfRenderingPage(); ResourceManager newMgr = new ResourceManager(true); newMgr.RenderScripts = ResourceLocationType.None; newMgr.RenderStyles = ResourceLocationType.None; newMgr.IDMode = IDMode.Explicit; newMgr.IsDynamic = true; pageHolder.Controls.Add(newMgr); if (this.ResourceManager == null) { this.ResourceManager = newMgr; } pageHolder.Controls.Add(this.Control); } else if (selfRendering && this.Control.Page is ISelfRenderingPage) { pageHolder = this.Control.Page; ResourceManager newMgr = Ext.Net.Utilities.ControlUtils.FindControl <ResourceManager>(pageHolder); if (this.ResourceManager == null) { this.ResourceManager = newMgr; } if (newMgr != null) { newMgr.IsDynamic = true; } } StringBuilder sb = new StringBuilder(); if (this.Control.ClientID.IsNotEmpty() && !this.Control.IsGeneratedID) { sb.AppendFormat("Ext.net.ResourceMgr.destroyCmp(\"{0}\");", this.Control.ClientID); } if (clearContainer) { if (mode == RenderMode.AddTo || mode == RenderMode.InsertTo) { string elementGet = element.Contains(".") ? element : "Ext.getCmp({0})".FormatWith(JSON.Serialize(element)); sb.AppendFormat("{0}.removeAll();", elementGet); } else if (mode != RenderMode.Replace) { sb.AppendFormat("Ext.net.getEl(\"{0}\").update();", element); } } List <BaseControl> childControls = this.FindControls(this.Control, selfRendering, sb, null, null); childControls.Insert(0, this.Control); if (selfRendering && pageHolder != null) { pageHolder.Items["Ext.Net.DeferInitScriptGeneration"] = new object(); } foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { if (c.AutoDataBind) { c.DataBind(); } } } if (selfRendering) { this.RegisterHtml(sb, pageHolder); if (pageHolder != null) { pageHolder.Items["Ext.Net.DeferInitScriptGeneration"] = null; } List <BaseControl> newChildControls = this.FindControls(this.Control, false, sb, null, null); newChildControls.Insert(0, this.Control); foreach (BaseControl c in newChildControls) { if (!childControls.Contains(c) && (c.Visible || Object.ReferenceEquals(c, this.Control))) { if (c.AutoDataBind) { c.DataBind(); } } } childControls = newChildControls; } foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { c.OnClientInit(true); c.RegisterBeforeAfterScript(); } } string methodTemplate = string.Concat(".", method ?? "add", "("); if (mode == RenderMode.InsertTo) { methodTemplate = string.Concat(".", method ?? "insert", "(", index.Value, ","); } foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { if (Object.ReferenceEquals(c, this.Control) && (this.Control.IsLazy || this.Control.ForceLazy)) { this.ScriptClientInitBag.Add(c.ClientInitID + "_BeforeScript", c.BeforeScript); string initScript = c.BuildInitScript(); string topScript = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.ItemTag), new Dictionary <string, string> { { "ref", "top_dynamic_control" }, { "index", ResourceManager.ScriptOrderNumber.ToString() } }, initScript); this.ScriptClientInitBag.Add(c.ClientInitID, topScript); this.ScriptClientInitBag.Add(c.ClientInitID + "_AfterScript", c.AfterScript); } else { string tokenValue = ((c is LazyObservable && c.IsIdRequired) ? "window.{0}=".FormatWith(c.ClientID) : "") + c.BuildInitScript(); string script = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.ItemTag), new Dictionary <string, string> { { "ref", c.IsLazy ? c.ClientInitID : "init_script" }, { "index", ResourceManager.ScriptOrderNumber.ToString() } }, tokenValue); this.ScriptClientInitBag.Add(c.ClientInitID, script); } c.AlreadyRendered = true; foreach (KeyValuePair <long, string> proxyScript in c.ProxyScripts) { if (proxyScript.Value.IsNotEmpty()) { this.ScriptOnReadyBag.Add(proxyScript.Key, proxyScript.Value); } } } } if (this.ScriptClientInitBag.Count > 0) { foreach (KeyValuePair <string, string> item in this.ScriptClientInitBag) { sb.Append(this.ScriptClientInitBag[item.Key]); } } sb.Append(Transformer.NET.Net.CreateToken(typeof(Transformer.NET.AnchorTag), new Dictionary <string, string> { { "id", "init_script" } })); string topAnchor = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.AnchorTag), new Dictionary <string, string> { { "id", "top_dynamic_control" } }); if (mode == RenderMode.AddTo || mode == RenderMode.InsertTo) { string elementGet = element.Contains(".") ? element : "Ext.getCmp({0})".FormatWith(JSON.Serialize(element)); sb.Append(elementGet.ConcatWith(methodTemplate, topAnchor, ");")); } else if (mode == RenderMode.Replace) { sb.Append("Ext.net._renderTo(arguments[0],".ConcatWith(topAnchor, ");")); } foreach (KeyValuePair <long, string> script in this.ScriptOnReadyBag) { sb.Append(script.Value); } if (mode == RenderMode.Replace) { string elementGet = element.Contains(".") ? element : "Ext.getCmp({0})".FormatWith(JSON.Serialize(element)); sb.Insert(0, elementGet + ".replace(function(){"); sb.Append("});"); } this.script = this.RegisterResources(sb.ToString()); } this.Control.ForceLazy = false; return(Transformer.NET.Html.HtmlTransformer.Transform(this.script)); }
public virtual string Build(RenderMode mode, string element, int? index, bool selfRendering, bool forceResources, string method, bool forceLazy) { this.ForceResources = forceResources; if (this.script == null) { AbstractComponent cmp = this.Control as AbstractComponent; switch (mode) { case RenderMode.RenderTo: if (cmp == null) { throw new Exception("RenderTo mode can be applied to only a AbstractComponent."); } if (string.IsNullOrEmpty(element)) { element = "={Ext.net.ResourceMgr.getRenderTarget()}"; } if (this.Control.IsLazy) { throw new Exception("Lazy control can be rendered with Automatic render mode only."); } cmp.RenderTo = element; break; case RenderMode.AddTo: case RenderMode.InsertTo: if (cmp == null) { throw new Exception("AddTo mode can be applied to only a AbstractComponent."); } if (string.IsNullOrEmpty(element)) { throw new Exception("You must specify an Element for the AddTo mode."); } if (this.Control.IsLazy) { //throw new Exception("Lazy controls can be rendered in Automatic mode only."); } if (mode == RenderMode.InsertTo && index == null) { throw new Exception("You have to provide the index for the InsertTo mode."); } cmp.PreventRenderTo = true; break; } Page pageHolder = null; bool isLazy = this.Control.IsLazy; this.Control.IsDynamicLazy = isLazy || (mode == RenderMode.AddTo || mode == RenderMode.InsertTo); Control parent = null; this.Control.TopDynamicControl = true; this.Control.ForceIdRendering = true; this.Control.ForceLazy = forceLazy; if (selfRendering && this.Control.Page == null) { pageHolder = new SelfRenderingPage(); ResourceManager newMgr = new ResourceManager(true); newMgr.RenderScripts = ResourceLocationType.None; newMgr.RenderStyles = ResourceLocationType.None; newMgr.IDMode = IDMode.Explicit; newMgr.IsDynamic = true; pageHolder.Controls.Add(newMgr); this.ResourceManager = newMgr; pageHolder.Controls.Add(this.Control); } else if (selfRendering && this.Control.Page is ISelfRenderingPage) { pageHolder = this.Control.Page; ResourceManager newMgr = Ext.Net.Utilities.ControlUtils.FindControl<ResourceManager>(pageHolder); this.ResourceManager = newMgr; if (newMgr != null) { newMgr.IsDynamic = true; } } StringBuilder sb = new StringBuilder(); if (this.Control.ClientID.IsNotEmpty() && !this.Control.IsGeneratedID) { sb.AppendFormat("Ext.net.ResourceMgr.destroyCmp(\"{0}\");", this.Control.ClientID); } List<BaseControl> childControls = this.FindControls(this.Control, selfRendering, sb, null, null); childControls.Insert(0, this.Control); foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { c.DeferInitScriptGeneration = selfRendering; if (c.AutoDataBind) { c.DataBind(); } } } if (selfRendering) { this.RegisterHtml(sb, pageHolder); foreach (BaseControl c in childControls) { c.DeferInitScriptGeneration = false; } List<BaseControl> newChildControls = this.FindControls(this.Control, false, sb, null, null); newChildControls.Insert(0, this.Control); foreach (BaseControl c in newChildControls) { if (!childControls.Contains(c) && (c.Visible || Object.ReferenceEquals(c, this.Control))) { if (c.AutoDataBind) { c.DataBind(); } } } childControls = newChildControls; } foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { c.OnClientInit(true); c.RegisterBeforeAfterScript(); } } string methodTemplate = string.Concat(".",method ?? "add","("); if (mode == RenderMode.InsertTo) { methodTemplate = string.Concat(".", method ?? "insert", "(", index.Value, ","); } foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { if (Object.ReferenceEquals(c, this.Control) && isLazy) { this.ScriptClientInitBag.Add(c.ClientInitID + "_BeforeScript", c.BeforeScript); string initScript = c.BuildInitScript(); if (selfRendering) { this.ScriptClientInitBag.Add(c.ClientInitID, initScript.ConcatWith(initScript.EndsWith(";") ? "" : ";", parent.ClientID.ConcatWith(methodTemplate, c.ClientID, ");"))); } else { this.ScriptClientInitBag.Add(c.ClientInitID, c.ParentComponent.ClientID.ConcatWith(methodTemplate, initScript, ");")); } this.ScriptClientInitBag.Add(c.ClientInitID + "_AfterScript", c.AfterScript); } else { string script = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.ItemTag), new Dictionary<string, string>{ {"ref", c.IsLazy ? c.ClientInitID : "init_script"}, {"index", ResourceManager.ScriptOrderNumber.ToString()} }, c.BuildInitScript()); this.ScriptClientInitBag.Add(c.ClientInitID, script); } c.AlreadyRendered = true; foreach (KeyValuePair<long, string> proxyScript in c.ProxyScripts) { if (proxyScript.Value.IsNotEmpty()) { this.ScriptOnReadyBag.Add(proxyScript.Key, proxyScript.Value); } } } } if (this.ScriptClientInitBag.Count > 0) { foreach (KeyValuePair<string, string> item in this.ScriptClientInitBag) { sb.Append(this.ScriptClientInitBag[item.Key]); } } sb.Append(Transformer.NET.Net.CreateToken(typeof(Transformer.NET.AnchorTag), new Dictionary<string, string>{ {"id", "init_script"} })); if (mode == RenderMode.AddTo || mode == RenderMode.InsertTo) { var elementGet = element.Contains(".") ? element : "Ext.getCmp({0})".FormatWith(JSON.Serialize(element)); sb.Append(elementGet.ConcatWith(methodTemplate, this.Control.ForceLazy ? this.Control.ConfigID : this.Control.ClientID, ");")); } foreach (KeyValuePair<long, string> script in this.ScriptOnReadyBag) { sb.Append(script.Value); } this.script = this.RegisterResources(sb.ToString()); } this.Control.ForceLazy = false; return Transformer.NET.Html.HtmlTransformer.Transform(this.script); }
/// <summary> /// /// </summary> /// <returns></returns> public virtual string SelfRender() { if (HttpContext.Current == null) { return ""; } SelfRenderingPage pageHolder = new SelfRenderingPage(); if (!(this is ResourceManager)) { ResourceManager newMgr = new ResourceManager(); newMgr.RenderScripts = ResourceLocationType.None; newMgr.RenderStyles = ResourceLocationType.None; newMgr.IDMode = IDMode.Explicit; newMgr.IsSelfRender = true; newMgr.IsDynamic = true; pageHolder.Controls.Add(newMgr); } this.IsSelfRender = true; this.IDMode = IDMode.Explicit; pageHolder.Controls.Add(this); StringWriter output = new StringWriter(); HttpContext.Current.Server.Execute(pageHolder, output, true); #if MVC this.IsSelfRender = this is Ext.Net.MVC.MvcResourceManager; #else this.IsSelfRender = false; #endif return output.ToString(); }
public virtual string Build(RenderMode mode, string element, int? index, bool selfRendering, bool forceResources) { this.ForceResources = forceResources; if (this.script == null) { Component cmp = this.Control as Component; switch (mode) { case RenderMode.RenderTo: if (cmp == null) { throw new Exception("RenderTo mode can be applied to only a Component."); } if (string.IsNullOrEmpty(element)) { throw new Exception("You must specify an element for RenderTo mode."); } if (this.Control.IsLazy) { throw new Exception("Lazy control can be rendered with Automatic render mode only."); } cmp.RenderTo = element; break; case RenderMode.AddTo: case RenderMode.InsertTo: if (cmp == null) { throw new Exception("AddTo mode can be applied to only a Component."); } if (string.IsNullOrEmpty(element)) { throw new Exception("You must specify an Element for the AddTo mode."); } if (this.Control.IsLazy) { //throw new Exception("Lazy controls can be rendered in Automatic mode only."); } if (mode == RenderMode.InsertTo && index == null) { throw new Exception("You have to provide the index for the InsertTo mode."); } cmp.AutoRender = false; break; } Page pageHolder = null; bool isLazy = this.Control.IsLazy; this.Control.IsDynamicLazy = isLazy || (mode == RenderMode.AddTo || mode == RenderMode.InsertTo); Control parent = null;// this.Control.ParentComponentNotLayout; this.Control.TopDynamicControl = true; this.Control.ForceIdRendering = true; if (selfRendering && this.Control.Page == null) { pageHolder = new SelfRenderingPage(); ResourceManager newMgr = new ResourceManager(); newMgr.RenderScripts = ResourceLocationType.None; newMgr.RenderStyles = ResourceLocationType.None; newMgr.IDMode = IDMode.Client; newMgr.IsDynamic = true; pageHolder.Controls.Add(newMgr); pageHolder.Controls.Add(this.Control); } else if (selfRendering && this.Control.Page is ISelfRenderingPage) { pageHolder = this.Control.Page; ResourceManager newMgr = ControlUtils.FindControl<ResourceManager>(pageHolder); if (newMgr != null) { newMgr.IsDynamic = true; } } StringBuilder sb = new StringBuilder(); List<XControl> childControls = this.FindControls(this.Control, selfRendering, sb, null); childControls.Insert(0, this.Control); /* foreach (XControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { c.EnsureDynamicID(); foreach (KeyValuePair<long, string> proxyScript in c.ProxyScripts) { if (proxyScript.Value.IsNotEmpty()) { this.ScriptOnReadyBag.Add(proxyScript.Key, proxyScript.Value); } } c.ProxyScripts.Clear(); } } foreach (KeyValuePair<long, string> script in this.ScriptOnReadyBag) { sb.Append(script.Value); } this.ScriptOnReadyBag.Clear(); */ if (this.Control.ClientID.IsNotEmpty()) { sb.AppendFormat("Ext.net.ResourceMgr.destroyCmp(\"{0}\");", this.Control.ClientID); } foreach (XControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { c.DeferInitScriptGeneration = selfRendering; if (c.AutoDataBind) { c.DataBind(); } } } if (selfRendering) { this.RegisterHtml(sb, pageHolder); foreach (XControl c in childControls) { c.DeferInitScriptGeneration = false; } List<XControl> newChildControls = this.FindControls(this.Control, false, sb, null); newChildControls.Insert(0, this.Control); foreach (XControl c in newChildControls) { if (!childControls.Contains(c) && (c.Visible || Object.ReferenceEquals(c, this.Control))) { if (c.AutoDataBind) { c.DataBind(); } } } childControls = newChildControls; } foreach (XControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { c.OnClientInit(true); c.RegisterBeforeAfterScript(); } } string methodTemplate = ".addAndDoLayout("; if (mode == RenderMode.InsertTo) { methodTemplate = ".insertAndDoLayout({0},".FormatWith(index.Value); } foreach (XControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { c.EnsureDynamicID(); if (Object.ReferenceEquals(c, this.Control) && isLazy) { this.ScriptClientInitBag.Add(c.ClientInitID + "_BeforeScript", c.BeforeScript); string initScript = c.BuildInitScript(); if (selfRendering) { this.ScriptClientInitBag.Add(c.ClientInitID, initScript.ConcatWith(initScript.EndsWith(";") ? "" : ";", parent.ClientID.ConcatWith(methodTemplate, c.ClientID, ");"))); } else { this.ScriptClientInitBag.Add(c.ClientInitID, c.ParentComponentNotLayout.ClientID.ConcatWith(methodTemplate, initScript, ");")); } this.ScriptClientInitBag.Add(c.ClientInitID + "_AfterScript", c.AfterScript); } else { this.ScriptClientInitBag.Add(c.ClientInitID, c.BuildInitScript()); } c.AlreadyRendered = true; foreach (KeyValuePair<long, string> proxyScript in c.ProxyScripts) { if (proxyScript.Value.IsNotEmpty()) { this.ScriptOnReadyBag.Add(proxyScript.Key, proxyScript.Value); } } } } if (this.ScriptClientInitBag.Count > 0) { foreach (KeyValuePair<string, string> item in this.ScriptClientInitBag) { sb.Append(this.Combine(item.Key)); } } if (mode == RenderMode.AddTo || mode == RenderMode.InsertTo) { sb.Append(element.ConcatWith(methodTemplate, this.Control.ClientID, ");")); } foreach (KeyValuePair<long, string> script in this.ScriptOnReadyBag) { sb.Append(script.Value); } this.script = this.RegisterResources(sb.ToString()); } return this.script; }
private ResourceManager __BuildControl__control8() { ResourceManager manager = new ResourceManager(); manager.ApplyStyleSheetSkin(this); object[] parameters = new object[5]; parameters[0] = manager; parameters[2] = 0x131; parameters[3] = 0x3a; parameters[4] = false; this.__PageInspector_SetTraceData(parameters); return manager; }
public virtual string Build(LazyMode mode) { if (this.script == null) { AbstractComponent cmp = this.Control as AbstractComponent; if (cmp != null) { cmp.PreventRenderTo = true; } this.Control.IsDynamicLazy = true; this.Control.TopDynamicControl = true; StringBuilder sb = new StringBuilder(); List <BaseControl> childControls = this.FindControls(this.Control, false, null, null, null); childControls.Insert(0, this.Control); foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { if (c.AutoDataBind) { c.DataBind(); } } } SelfRenderingPage pageHolder = new SelfRenderingPage(); ResourceManager newMgr = new ResourceManager(true); newMgr.RenderScripts = ResourceLocationType.None; newMgr.RenderStyles = ResourceLocationType.None; newMgr.IDMode = IDMode.Explicit; newMgr.IsDynamic = true; pageHolder.Controls.Add(newMgr); pageHolder.Controls.Add(this.Control); pageHolder.Items["Ext.Net.DeferInitScriptGeneration"] = new object(); string html = this.Control is INoneContentable ? null : BaseScriptBuilder.RenderControl(this.Control, pageHolder); pageHolder.Items["Ext.Net.DeferInitScriptGeneration"] = null; List <BaseControl> newChildControls = this.FindControls(this.Control, false, sb, null, null); newChildControls.Insert(0, this.Control); foreach (BaseControl c in newChildControls) { if (!childControls.Contains(c) && (c.Visible || Object.ReferenceEquals(c, this.Control))) { if (c.AutoDataBind) { c.DataBind(); } } } childControls = newChildControls; foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { c.OnClientInit(true); c.RegisterBeforeAfterScript(); } } foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { if (Object.ReferenceEquals(c, this.Control)) { string initScript; if (this.Control is ICustomConfigSerialization) { initScript = ((ICustomConfigSerialization)c).ToScript(c); } else { initScript = mode == LazyMode.Instance ? "new {0}({1})".FormatWith(c.InstanceOf, c.InitialConfig) : c.InitialConfig; } this.ScriptClientInitBag.Add(c.ClientInitID, initScript); } else { string script = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.ItemTag), new Dictionary <string, string> { { "ref", c.IsLazy ? c.ClientInitID : "init_script" }, { "index", ResourceManager.ScriptOrderNumber.ToString() } }, c.BuildInitScript()); this.ScriptClientInitBag.Add(c.ClientInitID, script); } c.AlreadyRendered = true; } } if (this.ScriptClientInitBag.Count > 0) { foreach (KeyValuePair <string, string> item in this.ScriptClientInitBag) { sb.Append(this.ScriptClientInitBag[item.Key]); } } string initToken = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.AnchorTag), new Dictionary <string, string> { { "id", "init_script" } }); if (html.IsNotEmpty()) { sb.Insert(sb.ToString().IndexOf('{') + 1, "contentHtml:function(){{{0}{1}}},".FormatWith(html, initToken)); } else { sb.Append(initToken); } this.script = sb.ToString(); } string config = Transformer.NET.Html.HtmlTransformer.Transform(this.script); return(config); }
protected override void RegisterControlResourcesInManager(ResourceManager manager, BaseControl ctrl) { }
/// <summary> /// /// </summary> /// <param name="control"></param> protected override void CheckResources(BaseControl control, ResourceManager manager) { }
public virtual string Build(LazyMode mode) { if (this.script == null) { AbstractComponent cmp = this.Control as AbstractComponent; if (cmp != null) { cmp.PreventRenderTo = true; } this.Control.IsDynamicLazy = true; this.Control.TopDynamicControl = true; StringBuilder sb = new StringBuilder(); List<BaseControl> childControls = this.FindControls(this.Control, false, null, null, null); childControls.Insert(0, this.Control); foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { if (c.AutoDataBind) { c.DataBind(); } } } SelfRenderingPage pageHolder = new SelfRenderingPage(); ResourceManager newMgr = new ResourceManager(true); newMgr.RenderScripts = ResourceLocationType.None; newMgr.RenderStyles = ResourceLocationType.None; newMgr.IDMode = IDMode.Explicit; newMgr.IsDynamic = true; pageHolder.Controls.Add(newMgr); pageHolder.Controls.Add(this.Control); pageHolder.Items["Ext.Net.DeferInitScriptGeneration"] = new object(); string html = this.Control is INoneContentable ? null : BaseScriptBuilder.RenderControl(this.Control, pageHolder); pageHolder.Items["Ext.Net.DeferInitScriptGeneration"] = null; List<BaseControl> newChildControls = this.FindControls(this.Control, false, sb, null, null); newChildControls.Insert(0, this.Control); foreach (BaseControl c in newChildControls) { if (!childControls.Contains(c) && (c.Visible || Object.ReferenceEquals(c, this.Control))) { if (c.AutoDataBind) { c.DataBind(); } } } childControls = newChildControls; foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { c.OnClientInit(true); c.RegisterBeforeAfterScript(); } } foreach (BaseControl c in childControls) { if (c.Visible || Object.ReferenceEquals(c, this.Control)) { if (Object.ReferenceEquals(c, this.Control)) { string initScript; if (this.Control is ICustomConfigSerialization) { initScript = ((ICustomConfigSerialization)c).ToScript(c); } else { initScript = mode == LazyMode.Instance ? "new {0}({1})".FormatWith(c.InstanceOf, c.InitialConfig) : c.InitialConfig; } this.ScriptClientInitBag.Add(c.ClientInitID, initScript); } else { string script = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.ItemTag), new Dictionary<string, string>{ {"ref", c.IsLazy ? c.ClientInitID : "init_script"}, {"index", ResourceManager.ScriptOrderNumber.ToString()} }, c.BuildInitScript()); this.ScriptClientInitBag.Add(c.ClientInitID, script); } c.AlreadyRendered = true; } } if (this.ScriptClientInitBag.Count > 0) { foreach (KeyValuePair<string, string> item in this.ScriptClientInitBag) { sb.Append(this.ScriptClientInitBag[item.Key]); } } string initToken = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.AnchorTag), new Dictionary<string, string>{ {"id", "init_script"} }); if (html.IsNotEmpty()) { sb.Insert(sb.ToString().IndexOf('{') + 1, "contentHtml:function(){{{0}{1}}},".FormatWith(html, initToken)); } else { sb.Append(initToken); } this.script = sb.ToString(); } string config = Transformer.NET.Html.HtmlTransformer.Transform(this.script); return config; }
public override void ProcessRequest(HttpContext context) { this.context = context; string file = this.context.Request.RawUrl; bool isInitScript = file.Contains("extnet/extnet-init-js/ext.axd?"); if ((!isInitScript && !ResourceHandler.IsSourceModified(context.Request)) || (isInitScript && !string.IsNullOrEmpty(context.Request.Headers["If-Modified-Since"]))) { context.Response.SuppressContent = true; context.Response.StatusCode = 304; context.Response.StatusDescription = "Not Modified"; context.Response.AddHeader("Content-Length", "0"); return; } this.SetResponseCache(context); if (isInitScript) { string key = file.RightOfRightmostOf('?'); if (key.IsNotEmpty()) { try { string script = this.context.Application[key].ToString(); this.context.Application.Remove(key); CompressionUtils.GZipAndSend(script); } catch (NullReferenceException) { throw new InitializationScriptNotFoundException("The Ext.NET initialization script was not found."); } } } else { try { this.sm = new ResourceManager(); this.compress = CompressionUtils.IsGZipSupported && this.sm.GZip; this.SetWebResourceName(file); this.stream = this.GetType().Assembly.GetManifestResourceStream(this.webResource); string ext = this.webResource.RightOfRightmostOf('.'); this.compress = this.compress && !this.IsImage(ext); switch (ext) { case "js": this.WriteFile("text/javascript"); break; case "css": this.WriteFile("text/css"); break; case "gif": this.WriteImage("image/gif"); break; case "png": this.WriteImage("image/png"); break; case "jpg": case "jpeg": this.WriteImage("image/jpg"); break; } } catch (Exception e) { string s = this.IsDebugging ? e.ToString() : e.Message; context.Response.StatusDescription = s.Substring(0, Math.Min(s.Length, 512)); this.context.Response.Redirect(Page.ClientScript.GetWebResourceUrl(this.sm.GetType(), this.webResource)); } finally { if (this.stream != null) { this.stream.Close(); } } } }
/// <summary> /// /// </summary> /// <param name="control"></param> protected virtual void CheckResources(BaseControl control, ResourceManager manager) { if (HttpContext.Current.CurrentHandler is Page && !(HttpContext.Current.CurrentHandler is ISelfRenderingPage) && !this.ForceResources) { return; } foreach (ClientScriptItem item in control.GetScripts()) { string resourcePath = manager != null && manager.ScriptMode == ScriptMode.Debug && item.PathEmbeddedDebug.IsNotEmpty() ? item.PathEmbeddedDebug : item.PathEmbedded; if (!scriptsResources.ContainsKey(resourcePath)) { scriptsResources.Add(resourcePath, GetWebResourceUrl(item.Type, resourcePath)); } } foreach (ClientStyleItem item in control.GetStyles()) { if (!stylesResources.ContainsKey(item.PathEmbedded) && item.Theme.Equals(Theme.Default)) { stylesResources.Add(item.PathEmbedded, GetWebResourceUrl(item.Type, item.PathEmbedded)); } } }
public static string RenderControl(Control control, Page pageHolder) { if (pageHolder == null) { pageHolder = new SelfRenderingPage(); ResourceManager newMgr = new ResourceManager(true); newMgr.RenderScripts = ResourceLocationType.None; newMgr.RenderStyles = ResourceLocationType.None; newMgr.IDMode = IDMode.Explicit; newMgr.IsDynamic = true; pageHolder.Controls.Add(newMgr); pageHolder.Controls.Add(control); } StringWriter output = new StringWriter(); HttpContext.Current.Server.Execute(pageHolder, output, true); StringBuilder sb = new StringBuilder(); //MatchCollection mc = Regex.Matches(output.ToString(), string.Concat(XControl.TOP_DYNAMIC_CONTROL_TAG_S, "(.*?)", XControl.TOP_DYNAMIC_CONTROL_TAG_E), RegexOptions.Singleline); MatchCollection mc = TopDynamic_RE.Matches(output.ToString()); foreach (Match m in mc) { sb.Append(m.Groups[1].Value); } return sb.ToString() ?? ""; }
private static string FormatArgs(object[] args) { StringBuilder sb = new StringBuilder(); if (args != null && args.Length > 0) { foreach (object arg in args) { if (arg is string) { sb.AppendFormat("{0},", TokenUtils.ParseAndNormalize(arg.ToString(), ResourceManager.GetInstance(HttpContext.Current))); } else { sb.AppendFormat("{0},", JSON.Serialize(arg)); } } } return(sb.ToString().LeftOfRightmostOf(',')); }
protected virtual void RegisterControlResourcesInManager(ResourceManager manager, BaseControl ctrl) { ctrl.RegisterStyles(manager); ctrl.RegisterScripts(manager); }
public override void ExecuteResult(ControllerContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (String.IsNullOrEmpty(this.ViewName)) { ViewName = context.RouteData.GetRequiredString("action"); } string id = this.ControlId ?? "ID_"+Guid.NewGuid().ToString().Replace("-", ""); string ct = this.ContainerId ?? "Ext.getBody()"; ViewDataDictionary dict = new ViewDataDictionary(ViewData); ViewEngineResult result = null; if (View == null) { result = this.ViewEngineCollection.FindPartialView(context, this.ViewName); //result = this.FindView(context); View = result.View; } string path = ((WebFormView)View).ViewPath; ViewContext viewContext = new ViewContext(context, View, ViewData, TempData, context.HttpContext.Response.Output); PartialViewPage pageHolder = new PartialViewPage { ViewData = dict, ViewContext = viewContext }; var curRM = HttpContext.Current.Items[typeof(ResourceManager)]; HttpContext.Current.Items[typeof(ResourceManager)] = null; ResourceManager rm = new ResourceManager(); rm.RenderScripts = ResourceLocationType.None; rm.RenderStyles = ResourceLocationType.None; rm.IDMode = this.IDMode; pageHolder.Controls.Add(rm); ViewUserControl uc = (ViewUserControl)pageHolder.LoadControl(path); uc.ID = id+"_UC"; uc.ViewData = ViewData; XControl controlToRender = null; if (this.ControlToRender.IsEmpty() && !this.SingleControl) { Panel p = new Panel { ID = id, IDMode = this.IDMode, Border = false, Header = false }; pageHolder.Controls.Add(p); p.ContentControls.Add(uc); controlToRender = p; } else { pageHolder.Controls.Add(uc); XControl c = null; if (this.SingleControl) { c = Ext.Net.Utilities.ControlUtils.FindControl<XControl>(uc); } else { c = Ext.Net.Utilities.ControlUtils.FindControl<XControl>(pageHolder, this.ControlToRender); } if (c == null) { if (this.SingleControl) { throw new Exception("Cannot find the Ext.Net control in the view"); } else { throw new Exception("Cannot find the control with ID=" + this.ControlToRender); } } controlToRender = c; if (controlToRender.IDMode == IDMode.Inherit) { controlToRender.IDMode = this.IDMode; } } pageHolder.InitHelpers(); string script = controlToRender.ToScript(this.RenderMode, ct, true); if(X.IsAjaxRequest) { script = "<Ext.Net.Direct.Response>" + script + "</Ext.Net.Direct.Response>"; } else if(this.WrapByScriptTag) { script = "<script type=\"text/javascript\">" + script + "</script>"; } IDisposable disposable = View as IDisposable; if (disposable != null) { disposable.Dispose(); } HttpContext.Current.Items[typeof(ResourceManager)] = curRM; context.HttpContext.Response.Write(script); }
public virtual string Build(bool selfRendering, bool forceResources) { this.ForceResources = forceResources; if (this.script == null) { Page pageHolder = null; this.Control.TopDynamicControl = true; this.Control.ForceIdRendering = true; this.ResourceManager = Ext.Net.ResourceManager.GetInstance(); if (selfRendering && this.Control.Page == null) { pageHolder = new SelfRenderingPage(); ResourceManager rm = new ResourceManager(true); rm.RenderScripts = ResourceLocationType.None; rm.RenderStyles = ResourceLocationType.None; rm.IDMode = IDMode.Explicit; rm.IsDynamic = true; pageHolder.Controls.Add(rm); if (this.ResourceManager == null) { this.ResourceManager = rm; } pageHolder.Controls.Add(this.Control); } else if (selfRendering && this.Control.Page is ISelfRenderingPage) { pageHolder = this.Control.Page; ResourceManager newMgr = Ext.Net.Utilities.ControlUtils.FindControl<ResourceManager>(pageHolder); if (this.ResourceManager == null) { this.ResourceManager = newMgr; } if (newMgr != null) { newMgr.IsDynamic = true; } } StringBuilder sb = new StringBuilder(); this.Control.ContentUpdated = this.Control.HasContent(); AbstractContainer container = this.Control as AbstractContainer; if (container != null) { sb.AppendFormat("{0}.removeAll();", this.Control.ClientID); } List<BaseControl> childControls = this.FindControls(this.Control, selfRendering, sb, null, null); if (selfRendering && pageHolder != null) { pageHolder.Items["Ext.Net.DeferInitScriptGeneration"] = new object(); } foreach (BaseControl c in childControls) { if (c.Visible) { if (c.AutoDataBind) { c.DataBind(); } } } if (selfRendering) { this.RegisterHtml(sb, pageHolder); if (pageHolder != null) { pageHolder.Items["Ext.Net.DeferInitScriptGeneration"] = null; } List<BaseControl> newChildControls = this.FindControls(this.Control, false, sb, null, null); if (this.Control.AutoDataBind) { this.Control.DataBind(); } foreach (BaseControl c in newChildControls) { if (!childControls.Contains(c) && c.Visible) { if (c.AutoDataBind) { c.DataBind(); } } } childControls = newChildControls; } foreach (BaseControl c in childControls) { if (c.Visible) { c.OnClientInit(true); c.RegisterBeforeAfterScript(); } } foreach (BaseControl c in childControls) { if (c.Visible) { string initScript = c.BuildInitScript(); if (!string.IsNullOrEmpty(initScript)) { if (this.layoutItems.Contains(c)) { this.ScriptClientInitBag.Add(c.ClientInitID, this.Control.ClientID.ConcatWith(".add(", initScript, ");")); } else { initScript = Transformer.NET.Net.CreateToken(typeof(Transformer.NET.ItemTag), new Dictionary<string, string>{ {"ref", c.IsLazy ? c.ClientInitID : "init_script"}, {"index", ResourceManager.ScriptOrderNumber.ToString()} }, initScript); this.ScriptClientInitBag.Add(c.ClientInitID, initScript); } } c.AlreadyRendered = true; foreach (KeyValuePair<long, string> proxyScript in c.ProxyScripts) { if (proxyScript.Value.IsNotEmpty()) { this.ScriptOnReadyBag.Add(proxyScript.Key, proxyScript.Value); } } } } if (this.ScriptClientInitBag.Count > 0) { foreach (KeyValuePair<string, string> item in this.ScriptClientInitBag) { sb.Append(this.ScriptClientInitBag[item.Key]); } } foreach (KeyValuePair<long, string> script in this.ScriptOnReadyBag) { sb.Append(script.Value); } if (container != null && container.Items.Count > 0) { sb.AppendFormat("{0}.doLayout();", this.Control.ClientID); } sb.Append(Transformer.NET.Net.CreateToken(typeof(Transformer.NET.AnchorTag), new Dictionary<string, string>{ {"id", "init_script"} })); this.script = this.RegisterResources(sb.ToString()); } return Transformer.NET.Html.HtmlTransformer.Transform(this.script); }
public virtual void Confirm(string msg, string handler) { string tpl = @"(function(){{var result=confirm(""{0}"");{1}}})();"; ResourceManager.GetInstance(HttpContext.Current).AddScript(tpl, msg, handler); }