Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DispatcherExceptionFilterEventArgs.cs
- XmlSecureResolver.cs
- XmlElement.cs
- OneOf.cs
- BuildProviderCollection.cs
- EnumValidator.cs
- XNodeValidator.cs
- HttpBrowserCapabilitiesBase.cs
- followingsibling.cs
- streamingZipPartStream.cs
- RuntimeConfigurationRecord.cs
- ResolveRequestResponseAsyncResult.cs
- ScrollProperties.cs
- HtmlImage.cs
- _NetRes.cs
- TemplateBaseAction.cs
- MasterPageParser.cs
- XPathEmptyIterator.cs
- Vector.cs
- SafeArrayRankMismatchException.cs
- SqlConnectionHelper.cs
- SerializationInfoEnumerator.cs
- CreateUserErrorEventArgs.cs
- Listen.cs
- _SSPISessionCache.cs
- Table.cs
- FrameworkElementFactory.cs
- MbpInfo.cs
- PassportAuthenticationEventArgs.cs
- WebPartConnectionsCancelVerb.cs
- printdlgexmarshaler.cs
- DoubleAnimation.cs
- StrongNameUtility.cs
- FixedBufferAttribute.cs
- Route.cs
- SystemDropShadowChrome.cs
- AutomationElementCollection.cs
- ToolStripTextBox.cs
- ClassValidator.cs
- SelectionRangeConverter.cs
- TransactionFlowBindingElementImporter.cs
- EventDescriptorCollection.cs
- CodeAttributeDeclarationCollection.cs
- ScriptResourceAttribute.cs
- EventsTab.cs
- ExpandedWrapper.cs
- Utils.cs
- ProtocolElement.cs
- ObjectDataSourceStatusEventArgs.cs
- EmptyElement.cs
- BindingObserver.cs
- ZipIOExtraFieldPaddingElement.cs
- RotationValidation.cs
- InstanceData.cs
- FreeFormDesigner.cs
- Bold.cs
- WorkflowDefinitionDispenser.cs
- Int16KeyFrameCollection.cs
- MatrixStack.cs
- UITypeEditor.cs
- ConnectionManagementElementCollection.cs
- RichTextBox.cs
- ColumnMapProcessor.cs
- FormatConvertedBitmap.cs
- LineInfo.cs
- TextElementCollection.cs
- StringSource.cs
- BufferedGraphicsContext.cs
- TextStore.cs
- Win32PrintDialog.cs
- StringDictionaryEditor.cs
- PresentationAppDomainManager.cs
- FormViewPagerRow.cs
- SelectionWordBreaker.cs
- PageParser.cs
- MatrixTransform3D.cs
- IntSecurity.cs
- XmlSchemaAnyAttribute.cs
- ResXDataNode.cs
- BulletedList.cs
- Choices.cs
- Rule.cs
- _AutoWebProxyScriptWrapper.cs
- OrthographicCamera.cs
- BreakRecordTable.cs
- HandleInitializationContext.cs
- WebCategoryAttribute.cs
- XPathMessageFilterElement.cs
- ContractCodeDomInfo.cs
- ImageDrawing.cs
- StackOverflowException.cs
- MediaCommands.cs
- DBParameter.cs
- AutomationPropertyInfo.cs
- SiteMapProvider.cs
- MSHTMLHost.cs
- HyperlinkAutomationPeer.cs
- Base64Stream.cs
- AnimatedTypeHelpers.cs
- CacheForPrimitiveTypes.cs