Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / xsp / System / Web / Extensions / ui / ScriptRegistrationManager.cs / 1 / 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
- MessageEnumerator.cs
- DeploymentSection.cs
- ToggleButton.cs
- CodeVariableDeclarationStatement.cs
- EntitySqlQueryCacheEntry.cs
- PenThreadWorker.cs
- CursorInteropHelper.cs
- CodeEventReferenceExpression.cs
- SingleResultAttribute.cs
- XmlSignatureProperties.cs
- EntityContainerEmitter.cs
- ToolStripItemCollection.cs
- XPathAxisIterator.cs
- RangeValueProviderWrapper.cs
- DbTransaction.cs
- PrimitiveXmlSerializers.cs
- SqlBulkCopy.cs
- SystemUdpStatistics.cs
- Span.cs
- SamlSubject.cs
- ParamArrayAttribute.cs
- EventLogPermissionEntry.cs
- DataPagerFieldCommandEventArgs.cs
- StrokeNodeOperations2.cs
- NumericPagerField.cs
- QueryNode.cs
- Odbc32.cs
- SoapExtension.cs
- DockPanel.cs
- AssertFilter.cs
- SendMailErrorEventArgs.cs
- WebException.cs
- TemplateInstanceAttribute.cs
- PrimaryKeyTypeConverter.cs
- EventlogProvider.cs
- ExecutionProperties.cs
- ToolStripPanel.cs
- SizeChangedInfo.cs
- EmptyEnumerator.cs
- ADConnectionHelper.cs
- Aggregates.cs
- DrawListViewColumnHeaderEventArgs.cs
- RequestSecurityTokenForGetBrowserToken.cs
- BindingExpression.cs
- HashCodeCombiner.cs
- Matrix3D.cs
- XsltArgumentList.cs
- QilTypeChecker.cs
- CompositeKey.cs
- RecommendedAsConfigurableAttribute.cs
- StringConverter.cs
- DataSourceProvider.cs
- Int64AnimationBase.cs
- LOSFormatter.cs
- LayoutTableCell.cs
- ConsoleTraceListener.cs
- LineBreakRecord.cs
- ColorTransformHelper.cs
- PropagatorResult.cs
- RemotingClientProxy.cs
- TimeSpanStorage.cs
- WorkflowRuntimeService.cs
- String.cs
- JsonClassDataContract.cs
- CatalogZoneBase.cs
- WebConfigurationManager.cs
- DocobjHost.cs
- MasterPageParser.cs
- ValueType.cs
- KeyManager.cs
- RecommendedAsConfigurableAttribute.cs
- DataObjectCopyingEventArgs.cs
- WebConfigurationHostFileChange.cs
- WebConvert.cs
- Configuration.cs
- elementinformation.cs
- SQLDouble.cs
- SoundPlayer.cs
- TransactionBehavior.cs
- BooleanAnimationUsingKeyFrames.cs
- SqlDuplicator.cs
- Resources.Designer.cs
- BinarySecretKeyIdentifierClause.cs
- QuadraticBezierSegment.cs
- DataControlHelper.cs
- SkewTransform.cs
- Substitution.cs
- CssClassPropertyAttribute.cs
- SQLSingleStorage.cs
- sortedlist.cs
- ServiceMetadataBehavior.cs
- SelectedGridItemChangedEvent.cs
- RowParagraph.cs
- TabControlCancelEvent.cs
- StylusEventArgs.cs
- PrimarySelectionAdorner.cs
- ValidationErrorCollection.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- FaultPropagationRecord.cs
- RequestUriProcessor.cs