Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / xsp / System / Web / Extensions / ui / ScriptRegistrationManager.cs / 2 / ScriptRegistrationManager.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.Globalization; using System.Text; using System.Text.RegularExpressions; using System.Web.UI; using System.Web.Resources; using System.Web.Script.Serialization; internal sealed class ScriptRegistrationManager { private static Regex ScriptTagRegex = new Regex( @"", indexOfEndOfScriptBeginTag, StringComparison.OrdinalIgnoreCase); if (indexOfScriptEndTag == -1) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.ScriptRegistrationManager_NoCloseTag, activeRegistration.Type.FullName, activeRegistration.Key)); } string scriptBlockContents = scriptContent.Substring(indexOfEndOfScriptBeginTag, (indexOfScriptEndTag - indexOfEndOfScriptBeginTag)); // Turn the text content into a text attribute attrs.Add("text", scriptBlockContents); lastIndex = indexOfScriptEndTag + 9; } // Process all the explicit attributes on the script tag CaptureCollection attrnames = match.Groups["attrname"].Captures; CaptureCollection attrvalues = match.Groups["attrval"].Captures; for (int i = 0; i < attrnames.Count; i++) { string attribName = attrnames[i].ToString(); string attribValue = attrvalues[i].ToString(); // DevDev Bugs 123213: script elements registered with RegisterStartupScript are normally rendered // into the html of the page. Any html encoded values in the attributes are interpreted by the // browser, so the actual data is not html encoded. We must HtmlDecode any attribute values we find // here to remain consistent during async posts, since the data will be dynamically injected into // the dom, bypassing the browser's natural html decoding. attribValue = HttpUtility.HtmlDecode(attribValue); attrs.Add(attribName, attribValue); } // Serialize the attributes to JSON and write them out JavaScriptSerializer serializer = new JavaScriptSerializer(); string attrText = serializer.Serialize(attrs); PageRequestManager.EncodeString(writer, token, "ScriptContentWithTags", attrText); } CheckScriptTagTweenSpace(activeRegistration, scriptContent, lastIndex, scriptContent.Length - lastIndex); if (lastIndex == 0) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.ScriptRegistrationManager_NoTags, activeRegistration.Type.FullName, activeRegistration.Key)); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.Globalization; using System.Text; using System.Text.RegularExpressions; using System.Web.UI; using System.Web.Resources; using System.Web.Script.Serialization; internal sealed class ScriptRegistrationManager { private static Regex ScriptTagRegex = new Regex( @"", indexOfEndOfScriptBeginTag, StringComparison.OrdinalIgnoreCase); if (indexOfScriptEndTag == -1) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.ScriptRegistrationManager_NoCloseTag, activeRegistration.Type.FullName, activeRegistration.Key)); } string scriptBlockContents = scriptContent.Substring(indexOfEndOfScriptBeginTag, (indexOfScriptEndTag - indexOfEndOfScriptBeginTag)); // Turn the text content into a text attribute attrs.Add("text", scriptBlockContents); lastIndex = indexOfScriptEndTag + 9; } // Process all the explicit attributes on the script tag CaptureCollection attrnames = match.Groups["attrname"].Captures; CaptureCollection attrvalues = match.Groups["attrval"].Captures; for (int i = 0; i < attrnames.Count; i++) { string attribName = attrnames[i].ToString(); string attribValue = attrvalues[i].ToString(); // DevDev Bugs 123213: script elements registered with RegisterStartupScript are normally rendered // into the html of the page. Any html encoded values in the attributes are interpreted by the // browser, so the actual data is not html encoded. We must HtmlDecode any attribute values we find // here to remain consistent during async posts, since the data will be dynamically injected into // the dom, bypassing the browser's natural html decoding. attribValue = HttpUtility.HtmlDecode(attribValue); attrs.Add(attribName, attribValue); } // Serialize the attributes to JSON and write them out JavaScriptSerializer serializer = new JavaScriptSerializer(); string attrText = serializer.Serialize(attrs); PageRequestManager.EncodeString(writer, token, "ScriptContentWithTags", attrText); } CheckScriptTagTweenSpace(activeRegistration, scriptContent, lastIndex, scriptContent.Length - lastIndex); if (lastIndex == 0) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.ScriptRegistrationManager_NoTags, activeRegistration.Type.FullName, activeRegistration.Key)); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- _ListenerAsyncResult.cs
- MultiSelector.cs
- ButtonBase.cs
- DataGridBoolColumn.cs
- NavigatorInput.cs
- DocumentReference.cs
- QueryOpeningEnumerator.cs
- LowerCaseStringConverter.cs
- IFlowDocumentViewer.cs
- EntityContainer.cs
- SimpleModelProvider.cs
- DocumentSchemaValidator.cs
- Internal.cs
- SecurityHeaderLayout.cs
- BamlLocalizer.cs
- XmlImplementation.cs
- ToggleButtonAutomationPeer.cs
- RadioButtonFlatAdapter.cs
- BoundsDrawingContextWalker.cs
- DataSourceHelper.cs
- TabControl.cs
- ReliableMessagingVersionConverter.cs
- TripleDESCryptoServiceProvider.cs
- GlobalizationSection.cs
- DbReferenceCollection.cs
- DataGridAddNewRow.cs
- WebBaseEventKeyComparer.cs
- TextParaClient.cs
- ReadOnlyTernaryTree.cs
- HttpClientCertificate.cs
- DataGridColumnCollection.cs
- log.cs
- RuleElement.cs
- SemaphoreFullException.cs
- MailDefinition.cs
- IResourceProvider.cs
- SQLStringStorage.cs
- ValueOfAction.cs
- NoneExcludedImageIndexConverter.cs
- WebPartPersonalization.cs
- ComplexObject.cs
- OverrideMode.cs
- SqlDataSourceCache.cs
- BinarySerializer.cs
- InkCanvasFeedbackAdorner.cs
- InstanceData.cs
- QuerySettings.cs
- FlowDecisionDesigner.xaml.cs
- Label.cs
- SecurityContext.cs
- TextEffect.cs
- SqlColumnizer.cs
- DeferredRunTextReference.cs
- TableCell.cs
- PowerModeChangedEventArgs.cs
- SByteStorage.cs
- ElementHost.cs
- SoapSchemaImporter.cs
- SelectionItemProviderWrapper.cs
- Manipulation.cs
- XmlBinaryReader.cs
- CompilerLocalReference.cs
- ProviderBase.cs
- TemplateParser.cs
- ProjectionQueryOptionExpression.cs
- ActivityFunc.cs
- ManipulationDeltaEventArgs.cs
- ToolboxItemCollection.cs
- Events.cs
- PropertyGridView.cs
- ValueTable.cs
- Compensate.cs
- PagesChangedEventArgs.cs
- XmlSchemaComplexContentRestriction.cs
- HostSecurityManager.cs
- MultiAsyncResult.cs
- AndCondition.cs
- ProjectionCamera.cs
- WebPartMovingEventArgs.cs
- DecimalAnimation.cs
- MethodCallConverter.cs
- SafeFileMappingHandle.cs
- FixedSOMTextRun.cs
- Point3DCollection.cs
- EntryWrittenEventArgs.cs
- ToolStripDropDownButton.cs
- TypeDelegator.cs
- ConfigurationLockCollection.cs
- AutomationPropertyInfo.cs
- UnmanagedMemoryStreamWrapper.cs
- ProfileModule.cs
- ProvidersHelper.cs
- FormViewDeleteEventArgs.cs
- OdbcFactory.cs
- Assert.cs
- HitTestFilterBehavior.cs
- SchemaMerger.cs
- TextDecorationCollectionConverter.cs
- CorrelationToken.cs
- SQLStringStorage.cs