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
- ManipulationCompletedEventArgs.cs
- OpCopier.cs
- GridViewColumn.cs
- CLSCompliantAttribute.cs
- WindowsMenu.cs
- XXXInfos.cs
- Volatile.cs
- Int32Animation.cs
- AccessDataSource.cs
- PersonalizationProvider.cs
- OleDbSchemaGuid.cs
- ValueOfAction.cs
- PathFigureCollection.cs
- SafeRightsManagementQueryHandle.cs
- Char.cs
- IsolatedStoragePermission.cs
- PackWebRequest.cs
- SmtpFailedRecipientsException.cs
- OperationValidationEventArgs.cs
- Mutex.cs
- HtmlLink.cs
- FaultConverter.cs
- LabelInfo.cs
- TextParagraphCache.cs
- ConnectionStringsExpressionBuilder.cs
- FlowDocumentPaginator.cs
- DrawListViewItemEventArgs.cs
- OdbcEnvironment.cs
- DesignerSerializerAttribute.cs
- Inflater.cs
- KoreanCalendar.cs
- ClrProviderManifest.cs
- UInt32Converter.cs
- SingleTagSectionHandler.cs
- Size.cs
- NamespaceQuery.cs
- UInt16Storage.cs
- ViewStateModeByIdAttribute.cs
- CrossSiteScriptingValidation.cs
- TypedDataSetSchemaImporterExtension.cs
- DynamicUpdateCommand.cs
- TextInfo.cs
- EmptyEnumerator.cs
- GcHandle.cs
- MsmqMessageProperty.cs
- ProxyFragment.cs
- CommonDialog.cs
- WsiProfilesElement.cs
- IconConverter.cs
- ItemChangedEventArgs.cs
- AudioFormatConverter.cs
- RSAProtectedConfigurationProvider.cs
- DmlSqlGenerator.cs
- InvalidPropValue.cs
- SafeLocalMemHandle.cs
- SqlDataSourceFilteringEventArgs.cs
- SiteMapHierarchicalDataSourceView.cs
- PropertyChangedEventArgs.cs
- CollectionsUtil.cs
- EventLogPermissionEntry.cs
- TypeNameHelper.cs
- ViewStateModeByIdAttribute.cs
- codemethodreferenceexpression.cs
- ObjectCloneHelper.cs
- ThreadExceptionDialog.cs
- NameValuePair.cs
- DecoderReplacementFallback.cs
- wgx_commands.cs
- Transform3D.cs
- IsolatedStoragePermission.cs
- EditCommandColumn.cs
- FullTextBreakpoint.cs
- CapiSafeHandles.cs
- AlternateViewCollection.cs
- TagPrefixAttribute.cs
- ActiveXContainer.cs
- MetadataWorkspace.cs
- ServiceBehaviorElementCollection.cs
- IncrementalCompileAnalyzer.cs
- X509Extension.cs
- EntityDataSourceView.cs
- Function.cs
- UniqueIdentifierService.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- FixedFindEngine.cs
- XmlIncludeAttribute.cs
- DataGridView.cs
- TitleStyle.cs
- RijndaelManagedTransform.cs
- RemoteCryptoDecryptRequest.cs
- AdornedElementPlaceholder.cs
- Polyline.cs
- FileDialogPermission.cs
- XsltOutput.cs
- SetterTriggerConditionValueConverter.cs
- storepermission.cs
- OlePropertyStructs.cs
- Context.cs
- XmlEncodedRawTextWriter.cs
- UnmanagedMarshal.cs