internal void RegisterOnSubmitStatementInternal(ScriptKey key, string script) { if (string.IsNullOrEmpty(script)) { throw ExceptionUtil.ParameterNullOrEmpty("script"); } if (this._registeredOnSubmitStatements == null) { this._registeredOnSubmitStatements = new ListDictionary(); } int index = script.Length - 1; while ((index >= 0) && char.IsWhiteSpace(script, index)) { index--; } if ((index >= 0) && (script[index] != ';')) { script = script.Substring(0, index + 1) + ";" + script.Substring(index + 1); } if (!this._registeredOnSubmitStatements.Contains(key)) { this._registeredOnSubmitStatements.Add(key, script); } if (this._owner.PartialCachingControlStack != null) { foreach (BasePartialCachingControl control in this._owner.PartialCachingControlStack) { control.RegisterOnSubmitStatement(key, script); } } }
internal void RegisterScriptBlock(ScriptKey key, string script, ClientAPIRegisterType type) { switch (type) { case ClientAPIRegisterType.ClientScriptBlocks: this.RegisterScriptBlock(key, script, ref this._registeredClientScriptBlocks, ref this._clientScriptBlocks, false); break; case ClientAPIRegisterType.ClientScriptBlocksWithoutTags: this.RegisterScriptBlock(key, script, ref this._registeredClientScriptBlocks, ref this._clientScriptBlocks, true); break; case ClientAPIRegisterType.ClientStartupScripts: this.RegisterScriptBlock(key, script, ref this._registeredClientStartupScripts, ref this._clientStartupScripts, false); break; case ClientAPIRegisterType.ClientStartupScriptsWithoutTags: this.RegisterScriptBlock(key, script, ref this._registeredClientStartupScripts, ref this._clientStartupScripts, true); break; } if (this._owner.PartialCachingControlStack != null) { foreach (BasePartialCachingControl control in this._owner.PartialCachingControlStack) { control.RegisterScriptBlock(type, key, script); } } }
public void RenderActiveSubmitStatements(List <UpdatePanel> updatePanels, HtmlTextWriter writer) { Debug.Assert(writer != null, "Should always have a writer"); List <RegisteredScript> entriesToRender = new List <RegisteredScript>(); // no comparer needed because it will contain ScriptKeys which implement Equals ListDictionary uniqueEntries = new ListDictionary(); // For each entry registered in the page, check and see which ones // came from controls within UpdatePanels that are going to be updated. Control lastControl = null; foreach (RegisteredScript entry in ScriptSubmitStatements) { Control child = entry.Control; bool isActive = ((lastControl != null) && (child == lastControl)) || IsControlRegistrationActive(updatePanels, child, true); if (isActive) { lastControl = child; ScriptKey scriptKey = new ScriptKey(entry.Type, entry.Key); if (!uniqueEntries.Contains(scriptKey)) { entriesToRender.Add(entry); uniqueEntries.Add(scriptKey, entry); } } } foreach (RegisteredScript activeRegistration in entriesToRender) { PageRequestManager.EncodeString(writer, PageRequestManager.OnSubmitToken, null, activeRegistration.Script); } }
private bool RenderRegisteredScripts(HtmlTextWriter writer, ArrayList scripts, bool checkForScriptManagerRegistrations) { writer.WriteLine(); bool flag = false; checkForScriptManagerRegistrations &= this._registeredResourcesToSuppress != null; foreach (Tuple <ScriptKey, string, bool> tuple in scripts) { if (checkForScriptManagerRegistrations) { Dictionary <string, object> dictionary; ScriptKey key = tuple.Item1; if ((key.IsResource && this._registeredResourcesToSuppress.TryGetValue(key.Assembly, out dictionary)) && dictionary.ContainsKey(key.Key)) { continue; } } if (tuple.Item3) { if (!flag) { writer.Write(this._owner.EnableLegacyRendering ? "\r\n<script type=\"text/javascript\">\r\n<!--\r\n" : "\r\n<script type=\"text/javascript\">\r\n//<![CDATA[\r\n"); flag = true; } } else if (flag) { writer.Write(this._owner.EnableLegacyRendering ? "// -->\r\n</script>\r\n" : "//]]>\r\n</script>\r\n"); flag = false; } writer.Write(tuple.Item2); } return(flag); }
private void RegisterClientCall(ClientAPIRegisterType type, ScriptKey scriptKey, string stringParam2) { RegisterCallData data = new RegisterCallData { Type = type, Key = scriptKey, StringParam2 = stringParam2 }; if (this._cacheEntry.RegisteredClientCalls == null) { this._cacheEntry.RegisteredClientCalls = new ArrayList(); } this._cacheEntry.RegisteredClientCalls.Add(data); }
private void RegisterScriptBlock(ScriptKey key, string script, ref ListDictionary scriptBlocks, ref ArrayList scriptList, bool needsScriptTags) { if (scriptBlocks == null) { scriptBlocks = new ListDictionary(); scriptList = new ArrayList(); } if (!scriptBlocks.Contains(key)) { Tuple <ScriptKey, string, bool> tuple = new Tuple <ScriptKey, string, bool>(key, script, needsScriptTags); scriptBlocks.Add(key, null); scriptList.Add(tuple); } }
private void RegisterClientCall(ClientAPIRegisterType type, ScriptKey scriptKey, string stringParam2) { // Keep track of the call, in order to be able to call it again when there is a cache hit. RegisterCallData registerCallData = new RegisterCallData(); registerCallData.Type = type; registerCallData.Key = scriptKey; registerCallData.StringParam2 = stringParam2; if (_cacheEntry.RegisteredClientCalls == null) { _cacheEntry.RegisteredClientCalls = new ArrayList(); } _cacheEntry.RegisteredClientCalls.Add(registerCallData); }
public void RegisterClientScriptBlock(Type type, string key, string script) { var scriptKey = new ScriptKey(type, key); if(this.ScriptBlocks[scriptKey] == null) { this.ScriptBlocks.Add(scriptKey, script); } }
internal void RegisterScriptBlock(ClientAPIRegisterType type, ScriptKey key, string script) { RegisterClientCall(type, key, script); }
internal void RegisterOnSubmitStatement(ScriptKey key, string script) { RegisterClientCall(ClientAPIRegisterType.OnSubmitStatement, key, script); }
public void RenderActiveSubmitStatements(List<UpdatePanel> updatePanels, HtmlTextWriter writer) { Debug.Assert(writer != null, "Should always have a writer"); List<RegisteredScript> entriesToRender = new List<RegisteredScript>(); // no comparer needed because it will contain ScriptKeys which implement Equals ListDictionary uniqueEntries = new ListDictionary(); // For each entry registered in the page, check and see which ones // came from controls within UpdatePanels that are going to be updated. Control lastControl = null; foreach (RegisteredScript entry in ScriptSubmitStatements) { Control child = entry.Control; bool isActive = ((lastControl != null) && (child == lastControl)) || IsControlRegistrationActive(updatePanels, child, true); if (isActive) { lastControl = child; ScriptKey scriptKey = new ScriptKey(entry.Type, entry.Key); if (!uniqueEntries.Contains(scriptKey)) { entriesToRender.Add(entry); uniqueEntries.Add(scriptKey, entry); } } } foreach (RegisteredScript activeRegistration in entriesToRender) { PageRequestManager.EncodeString(writer, PageRequestManager.OnSubmitToken, null, activeRegistration.Script); } }
private void RegisterClientCall(ClientAPIRegisterType type, ScriptKey scriptKey, string stringParam2) { // Keep track of the call, in order to be able to call it again when there is a cache hit. RegisterCallData registerCallData = new RegisterCallData(); registerCallData.Type = type; registerCallData.Key = scriptKey; registerCallData.StringParam2 = stringParam2; if (_cacheEntry.RegisteredClientCalls == null) _cacheEntry.RegisteredClientCalls = new ArrayList(); _cacheEntry.RegisteredClientCalls.Add(registerCallData); }
private void RegisterScriptBlock(ScriptKey key, string script, ref ListDictionary scriptBlocks, ref ArrayList scriptList, bool needsScriptTags) { if (scriptBlocks == null) { scriptBlocks = new ListDictionary(); scriptList = new ArrayList(); } if (!scriptBlocks.Contains(key)) { Tuple<ScriptKey, String, Boolean> entry = new Tuple<ScriptKey, String, Boolean>(key, script, needsScriptTags); scriptBlocks.Add(key, null); scriptList.Add(entry); } }
private void RenderActiveScriptBlocks(List<UpdatePanel> updatePanels, HtmlTextWriter writer, string token, List<RegisteredScript> scriptRegistrations) { List<RegisteredScript> entriesToRender = new List<RegisteredScript>(); // no comparer needed because it will contain ScriptKeys which implement Equals ListDictionary uniqueEntries = new ListDictionary(); // For each entry registered in the page, check and see which ones // came from controls within UpdatePanels that are going to be updated. Control lastControl = null; foreach (RegisteredScript entry in scriptRegistrations) { Control child = entry.Control; bool isActive = ((lastControl != null) && (child == lastControl)) || IsControlRegistrationActive(updatePanels, child, true); if (isActive) { lastControl = child; ScriptKey scriptKey = new ScriptKey(entry.Type, entry.Key); if (!uniqueEntries.Contains(scriptKey)) { entriesToRender.Add(entry); uniqueEntries.Add(scriptKey, entry); } } } foreach (RegisteredScript activeRegistration in entriesToRender) { if (String.IsNullOrEmpty(activeRegistration.Url)) { if (activeRegistration.AddScriptTags) { PageRequestManager.EncodeString(writer, token, "ScriptContentNoTags", activeRegistration.Script); } else { WriteScriptWithTags(writer, token, activeRegistration); } } else { PageRequestManager.EncodeString(writer, token, "ScriptPath", activeRegistration.Url); } string fallbackScriptPath; if (_fallbackScripts != null && _fallbackScripts.TryGetValue(new ScriptKey(activeRegistration.Type, activeRegistration.Key), out fallbackScriptPath)) { // Only encode the fallback path and not the expression. On the client, we would use the success flag on load / readystatechanged to // determine if the script was successfully fetched. PageRequestManager.EncodeString(writer, "fallbackScript", fallbackScriptPath, content: null); } } }
internal void RegisterOnSubmitStatementInternal(ScriptKey key, string script) { if (String.IsNullOrEmpty(script)) { throw ExceptionUtil.ParameterNullOrEmpty("script"); } if (_registeredOnSubmitStatements == null) _registeredOnSubmitStatements = new ListDictionary(); // Make sure the script block ends in a semicolon int index = script.Length - 1; while ((index >= 0) && Char.IsWhiteSpace(script, index)) { index--; } if ((index >= 0) && (script[index] != ';')) { script = script.Substring(0, index + 1) + ";" + script.Substring(index + 1); } if (!_registeredOnSubmitStatements.Contains(key)) _registeredOnSubmitStatements.Add(key, script); // If there are any partial caching controls on the stack, forward the call to them if (_owner.PartialCachingControlStack != null) { foreach (BasePartialCachingControl c in _owner.PartialCachingControlStack) { c.RegisterOnSubmitStatement(key, script); } } }
internal void RegisterScriptBlock(ScriptKey key, string script, ClientAPIRegisterType type) { // Call RegisterScriptBlock with the correct collection based on the blockType switch (type) { case ClientAPIRegisterType.ClientScriptBlocks: RegisterScriptBlock(key, script, ref _registeredClientScriptBlocks, ref _clientScriptBlocks, false); break; case ClientAPIRegisterType.ClientScriptBlocksWithoutTags: RegisterScriptBlock(key, script, ref _registeredClientScriptBlocks, ref _clientScriptBlocks, true); break; case ClientAPIRegisterType.ClientStartupScripts: RegisterScriptBlock(key, script, ref _registeredClientStartupScripts, ref _clientStartupScripts, false); break; case ClientAPIRegisterType.ClientStartupScriptsWithoutTags: RegisterScriptBlock(key, script, ref _registeredClientStartupScripts, ref _clientStartupScripts, true); break; default: Debug.Assert(false); break; } // If there are any partial caching controls on the stack, forward the call to them if (_owner.PartialCachingControlStack != null) { foreach (BasePartialCachingControl c in _owner.PartialCachingControlStack) { c.RegisterScriptBlock(type, key, script); } } }
private void RenderActiveScriptBlocks(List <UpdatePanel> updatePanels, HtmlTextWriter writer, string token, List <RegisteredScript> scriptRegistrations) { List <RegisteredScript> entriesToRender = new List <RegisteredScript>(); // no comparer needed because it will contain ScriptKeys which implement Equals ListDictionary uniqueEntries = new ListDictionary(); // For each entry registered in the page, check and see which ones // came from controls within UpdatePanels that are going to be updated. Control lastControl = null; foreach (RegisteredScript entry in scriptRegistrations) { Control child = entry.Control; bool isActive = ((lastControl != null) && (child == lastControl)) || IsControlRegistrationActive(updatePanels, child, true); if (isActive) { lastControl = child; ScriptKey scriptKey = new ScriptKey(entry.Type, entry.Key); if (!uniqueEntries.Contains(scriptKey)) { entriesToRender.Add(entry); uniqueEntries.Add(scriptKey, entry); } } } foreach (RegisteredScript activeRegistration in entriesToRender) { if (String.IsNullOrEmpty(activeRegistration.Url)) { if (activeRegistration.AddScriptTags) { PageRequestManager.EncodeString(writer, token, "ScriptContentNoTags", activeRegistration.Script); } else { WriteScriptWithTags(writer, token, activeRegistration); } } else { PageRequestManager.EncodeString(writer, token, "ScriptPath", activeRegistration.Url); } string fallbackScriptPath; if (_fallbackScripts != null && _fallbackScripts.TryGetValue(new ScriptKey(activeRegistration.Type, activeRegistration.Key), out fallbackScriptPath)) { // Only encode the fallback path and not the expression. On the client, we would use the success flag on load / readystatechanged to // determine if the script was successfully fetched. PageRequestManager.EncodeString(writer, "fallbackScript", fallbackScriptPath, content: null); } } }
public override bool Equals(object o) { ScriptKey key = (ScriptKey)o; return(((key._type == this._type) && (key._key == this._key)) && (key._isInclude == this._isInclude)); }