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
- ListBox.cs
- BitmapPalettes.cs
- Base64Stream.cs
- XmlChildEnumerator.cs
- Misc.cs
- TrackBar.cs
- Span.cs
- XmlSerializationReader.cs
- CaseInsensitiveOrdinalStringComparer.cs
- __Error.cs
- TemplatePartAttribute.cs
- IIS7UserPrincipal.cs
- DocumentXmlWriter.cs
- MemberPath.cs
- TreeIterators.cs
- SqlDependencyListener.cs
- LinqDataSourceView.cs
- DataMisalignedException.cs
- DataGridItemEventArgs.cs
- Regex.cs
- DataSetSchema.cs
- ListItemConverter.cs
- ProjectionCamera.cs
- Button.cs
- TextBoxAutoCompleteSourceConverter.cs
- TouchPoint.cs
- DBCommand.cs
- QilParameter.cs
- XPathMultyIterator.cs
- ResponseStream.cs
- CatalogZone.cs
- EmulateRecognizeCompletedEventArgs.cs
- QilTernary.cs
- SmtpNegotiateAuthenticationModule.cs
- AttachedAnnotation.cs
- ReliableReplySessionChannel.cs
- ConfigurationValidatorAttribute.cs
- Speller.cs
- SubMenuStyle.cs
- storepermission.cs
- ReadContentAsBinaryHelper.cs
- DrawingCollection.cs
- RowVisual.cs
- RenderCapability.cs
- ISO2022Encoding.cs
- NativeMethods.cs
- StructuredTypeInfo.cs
- QueryableDataSourceView.cs
- RuntimeEnvironment.cs
- Stylesheet.cs
- SqlMethodTransformer.cs
- LayoutSettings.cs
- InternalDuplexChannelFactory.cs
- ExpressionWriter.cs
- KnownAssemblyEntry.cs
- GenericUriParser.cs
- DefaultPropertiesToSend.cs
- MobileListItemCollection.cs
- NetworkStream.cs
- RequestTimeoutManager.cs
- HandleCollector.cs
- XmlAggregates.cs
- DataGridViewSortCompareEventArgs.cs
- LastQueryOperator.cs
- SyndicationDeserializer.cs
- SystemFonts.cs
- ClientScriptManager.cs
- ImportCatalogPart.cs
- UnitySerializationHolder.cs
- BaseCollection.cs
- Missing.cs
- SendSecurityHeaderElement.cs
- EnvelopedSignatureTransform.cs
- TableColumn.cs
- StorageModelBuildProvider.cs
- XmlILStorageConverter.cs
- SqlDataSourceCommandEventArgs.cs
- AssociationTypeEmitter.cs
- StaticDataManager.cs
- WorkflowRuntimeServiceElementCollection.cs
- MultiAsyncResult.cs
- Pointer.cs
- Stylus.cs
- View.cs
- TextPattern.cs
- Content.cs
- httpapplicationstate.cs
- SortedDictionary.cs
- MappedMetaModel.cs
- TextBoxBase.cs
- PackWebResponse.cs
- SkinIDTypeConverter.cs
- ResourceReferenceExpression.cs
- PerformanceCountersElement.cs
- AccessibilityApplicationManager.cs
- DataControlPagerLinkButton.cs
- NullableConverter.cs
- SecurityKeyIdentifier.cs
- _NTAuthentication.cs
- XmlQueryStaticData.cs