Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / UI / ScriptRegistrationManager.cs / 1305376 / 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.Reflection; using System.Text; using System.Text.RegularExpressions; using System.Web.Handlers; using System.Web.Resources; using System.Web.Script.Serialization; using System.Web.UI; 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.Reflection; using System.Text; using System.Text.RegularExpressions; using System.Web.Handlers; using System.Web.Resources; using System.Web.Script.Serialization; using System.Web.UI; 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
- AtomServiceDocumentSerializer.cs
- ScriptMethodAttribute.cs
- QueryIntervalOp.cs
- PatternMatcher.cs
- WebPartChrome.cs
- MergeFilterQuery.cs
- BaseTemplateBuildProvider.cs
- SynchronizationLockException.cs
- SecurityDocument.cs
- NonParentingControl.cs
- FlowDocumentReaderAutomationPeer.cs
- Timer.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- CanonicalizationDriver.cs
- RemoteEndpointMessageProperty.cs
- TemplateNameScope.cs
- RegexBoyerMoore.cs
- CodePageUtils.cs
- StylusCaptureWithinProperty.cs
- SymmetricSecurityProtocolFactory.cs
- BinaryNode.cs
- DataServiceException.cs
- MobilePage.cs
- OutputWindow.cs
- XamlParser.cs
- RequestReplyCorrelator.cs
- SrgsRulesCollection.cs
- InputChannelAcceptor.cs
- Hex.cs
- Marshal.cs
- ProjectionPlan.cs
- SoapEnumAttribute.cs
- LingerOption.cs
- TableItemPatternIdentifiers.cs
- FormViewDeletedEventArgs.cs
- PropertyDescriptorCollection.cs
- LazyTextWriterCreator.cs
- SafeEventLogWriteHandle.cs
- SQLByteStorage.cs
- CodeCompiler.cs
- ImageProxy.cs
- ArraySubsetEnumerator.cs
- XmlNodeChangedEventManager.cs
- Unit.cs
- FormViewRow.cs
- QueryReaderSettings.cs
- XmlTextEncoder.cs
- InvalidPrinterException.cs
- DataGridViewColumn.cs
- BasePattern.cs
- LocalizableResourceBuilder.cs
- DateBoldEvent.cs
- ConstructorExpr.cs
- XPathDocument.cs
- Graph.cs
- Atom10FeedFormatter.cs
- ScrollBarRenderer.cs
- DataGridViewDataErrorEventArgs.cs
- StringExpressionSet.cs
- ChooseAction.cs
- ItemCollection.cs
- ContainerControl.cs
- QueryStringConverter.cs
- UInt16.cs
- HostingEnvironmentSection.cs
- TreeView.cs
- TargetPerspective.cs
- UInt16Converter.cs
- QueryOptionExpression.cs
- SHA1.cs
- JsonReaderWriterFactory.cs
- XamlWrapperReaders.cs
- RSACryptoServiceProvider.cs
- Memoizer.cs
- ResolvedKeyFrameEntry.cs
- LongValidator.cs
- UriWriter.cs
- FullTextBreakpoint.cs
- GridItemCollection.cs
- CellIdBoolean.cs
- MessageDesigner.cs
- BaseServiceProvider.cs
- SiteMapDesignerDataSourceView.cs
- BinaryObjectInfo.cs
- mediaclock.cs
- GZipDecoder.cs
- SegmentInfo.cs
- ProcessInputEventArgs.cs
- TreeNodeEventArgs.cs
- ChildTable.cs
- FamilyMap.cs
- BamlResourceSerializer.cs
- EditorZoneBase.cs
- NodeLabelEditEvent.cs
- IsolatedStorageFilePermission.cs
- BufferedGraphicsManager.cs
- CodeNamespaceImportCollection.cs
- HttpContext.cs
- SQLInt64Storage.cs
- TextDecorations.cs