Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- MenuItemAutomationPeer.cs
- AgileSafeNativeMemoryHandle.cs
- PartialTrustVisibleAssemblyCollection.cs
- PropertyIDSet.cs
- CollectionViewSource.cs
- WindowsPen.cs
- TextEndOfLine.cs
- SoapInteropTypes.cs
- CollectionTypeElement.cs
- XmlSchemaDocumentation.cs
- FailedToStartupUIException.cs
- BindableTemplateBuilder.cs
- RSAOAEPKeyExchangeFormatter.cs
- XPathNavigator.cs
- UserControlCodeDomTreeGenerator.cs
- XsdDataContractExporter.cs
- Selection.cs
- XamlToRtfParser.cs
- UrlPath.cs
- FilterException.cs
- SqlParameter.cs
- UndoManager.cs
- SafeRegistryHandle.cs
- GiveFeedbackEvent.cs
- SurrogateEncoder.cs
- SqlFacetAttribute.cs
- SchemaElementDecl.cs
- GridViewRowPresenter.cs
- ClientApiGenerator.cs
- RoleManagerModule.cs
- RetrieveVirtualItemEventArgs.cs
- BitmapFrame.cs
- DiagnosticsConfigurationHandler.cs
- AppLevelCompilationSectionCache.cs
- mediapermission.cs
- Vector3DValueSerializer.cs
- Util.cs
- IdnMapping.cs
- Profiler.cs
- ProgressBarRenderer.cs
- Pkcs7Signer.cs
- AttributeCollection.cs
- METAHEADER.cs
- DeploymentSection.cs
- WebPartDescriptionCollection.cs
- UIAgentMonitor.cs
- MediaCommands.cs
- SettingsPropertyWrongTypeException.cs
- Substitution.cs
- SafeArrayTypeMismatchException.cs
- BindToObject.cs
- DbConnectionStringBuilder.cs
- Light.cs
- TextTabProperties.cs
- EncoderExceptionFallback.cs
- SignedXml.cs
- PageFunction.cs
- XmlSchemaGroup.cs
- GPStream.cs
- ControlHelper.cs
- CopyCodeAction.cs
- BufferedStream.cs
- cookieexception.cs
- COM2ComponentEditor.cs
- WebBrowserContainer.cs
- PackUriHelper.cs
- XmlWhitespace.cs
- ReadOnlyPermissionSet.cs
- SoapIncludeAttribute.cs
- FileLevelControlBuilderAttribute.cs
- NavigationHelper.cs
- List.cs
- LineBreak.cs
- SingleObjectCollection.cs
- RoleServiceManager.cs
- XmlDictionaryString.cs
- SkinIDTypeConverter.cs
- ControlDesignerState.cs
- PreviewKeyDownEventArgs.cs
- DirectoryNotFoundException.cs
- DataGridViewCellLinkedList.cs
- safex509handles.cs
- FormsAuthenticationCredentials.cs
- StringSorter.cs
- CollectionViewGroupRoot.cs
- ExpandableObjectConverter.cs
- TextFormatter.cs
- PixelFormatConverter.cs
- TextServicesCompartment.cs
- WindowsComboBox.cs
- DataServiceRequestException.cs
- UInt16Converter.cs
- HttpHandlersSection.cs
- ActiveDesignSurfaceEvent.cs
- HttpBrowserCapabilitiesBase.cs
- InternalControlCollection.cs
- CustomCredentialPolicy.cs
- NativeMethods.cs
- WrappedOptions.cs
- DocumentXmlWriter.cs