Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / UI / WebControls / Substitution.cs / 1 / Substitution.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System; using System.ComponentModel; using System.Globalization; using System.Security.Permissions; using System.Web; using System.Web.UI; ////// [ DefaultProperty("MethodName"), Designer("System.Web.UI.Design.WebControls.SubstitutionDesigner, " + AssemblyRef.SystemDesign), ParseChildren(true), PersistChildren(false), ] [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class Substitution : Control { ////// /// public Substitution() { } ////// /// [ DefaultValue(""), WebCategory("Behavior"), WebSysDescription(SR.Substitution_MethodNameDescr) ] public virtual string MethodName { get { string s = ViewState["MethodName"] as string; return s == null? String.Empty : s; } set { ViewState["MethodName"] = value; } } protected override ControlCollection CreateControlCollection() { return new EmptyControlCollection(this); } // SECURITY CODE // VSWhidbey 253188: Permission assert to support page running below full trust [ReflectionPermission(SecurityAction.Assert, Flags=ReflectionPermissionFlag.MemberAccess)] private HttpResponseSubstitutionCallback GetDelegate(Type targetType, string methodName) { return (HttpResponseSubstitutionCallback)Delegate.CreateDelegate( typeof(HttpResponseSubstitutionCallback), targetType, methodName); } protected internal override void OnPreRender(EventArgs e) { base.OnPreRender(e); // VSWhidbey 84748: Temp fix, throw if we are within a cached control Control parent = Parent; while (parent != null) { if (parent is BasePartialCachingControl) { throw new HttpException( SR.GetString(SR.Substitution_CannotBeInCachedControl)); } parent = parent.Parent; } } protected internal override void Render(HtmlTextWriter writer) { RenderMarkup(writer); } internal void RenderMarkup(HtmlTextWriter writer) { if (MethodName.Length == 0) { return; } TemplateControl target = TemplateControl; if (target == null) { return; } // get the delegate to the method HttpResponseSubstitutionCallback callback = null; try { callback = GetDelegate(target.GetType(), MethodName); } catch { } if (callback == null) { throw new HttpException( SR.GetString(SR.Substitution_BadMethodName, MethodName)); } // add the substitution to the response Page.Response.WriteSubstitution(callback); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ ///// // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System; using System.ComponentModel; using System.Globalization; using System.Security.Permissions; using System.Web; using System.Web.UI; ////// [ DefaultProperty("MethodName"), Designer("System.Web.UI.Design.WebControls.SubstitutionDesigner, " + AssemblyRef.SystemDesign), ParseChildren(true), PersistChildren(false), ] [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class Substitution : Control { ////// /// public Substitution() { } ////// /// [ DefaultValue(""), WebCategory("Behavior"), WebSysDescription(SR.Substitution_MethodNameDescr) ] public virtual string MethodName { get { string s = ViewState["MethodName"] as string; return s == null? String.Empty : s; } set { ViewState["MethodName"] = value; } } protected override ControlCollection CreateControlCollection() { return new EmptyControlCollection(this); } // SECURITY CODE // VSWhidbey 253188: Permission assert to support page running below full trust [ReflectionPermission(SecurityAction.Assert, Flags=ReflectionPermissionFlag.MemberAccess)] private HttpResponseSubstitutionCallback GetDelegate(Type targetType, string methodName) { return (HttpResponseSubstitutionCallback)Delegate.CreateDelegate( typeof(HttpResponseSubstitutionCallback), targetType, methodName); } protected internal override void OnPreRender(EventArgs e) { base.OnPreRender(e); // VSWhidbey 84748: Temp fix, throw if we are within a cached control Control parent = Parent; while (parent != null) { if (parent is BasePartialCachingControl) { throw new HttpException( SR.GetString(SR.Substitution_CannotBeInCachedControl)); } parent = parent.Parent; } } protected internal override void Render(HtmlTextWriter writer) { RenderMarkup(writer); } internal void RenderMarkup(HtmlTextWriter writer) { if (MethodName.Length == 0) { return; } TemplateControl target = TemplateControl; if (target == null) { return; } // get the delegate to the method HttpResponseSubstitutionCallback callback = null; try { callback = GetDelegate(target.GetType(), MethodName); } catch { } if (callback == null) { throw new HttpException( SR.GetString(SR.Substitution_BadMethodName, MethodName)); } // add the substitution to the response Page.Response.WriteSubstitution(callback); } } } // 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
- AspNetSynchronizationContext.cs
- TextChangedEventArgs.cs
- DateTimeFormatInfo.cs
- XslCompiledTransform.cs
- DiscoveryVersion.cs
- TraceHandlerErrorFormatter.cs
- CommittableTransaction.cs
- SystemEvents.cs
- CustomWebEventKey.cs
- DesignerUtility.cs
- DataSourceConverter.cs
- BodyGlyph.cs
- RepeaterItemEventArgs.cs
- QilPatternFactory.cs
- MailAddressCollection.cs
- IncrementalHitTester.cs
- SqlParameterizer.cs
- CharAnimationUsingKeyFrames.cs
- Dictionary.cs
- ProcessThreadCollection.cs
- EntityFunctions.cs
- ReadOnlyCollection.cs
- BindingSource.cs
- BinaryKeyIdentifierClause.cs
- ExtensibleClassFactory.cs
- CacheDependency.cs
- DataContractJsonSerializer.cs
- SmtpAuthenticationManager.cs
- xdrvalidator.cs
- RowVisual.cs
- TraceUtils.cs
- Shape.cs
- DoWorkEventArgs.cs
- ListMarkerLine.cs
- FontDifferentiator.cs
- Brushes.cs
- DesignerResources.cs
- ObjectIDGenerator.cs
- StorageModelBuildProvider.cs
- SrgsElement.cs
- ThreadStateException.cs
- WorkflowMarkupSerializer.cs
- _DisconnectOverlappedAsyncResult.cs
- MessagePropertyVariants.cs
- HTMLTextWriter.cs
- ElementMarkupObject.cs
- PanelDesigner.cs
- CodeExporter.cs
- HTMLTextWriter.cs
- XmlSchemaImporter.cs
- URL.cs
- SqlInfoMessageEvent.cs
- TypeContext.cs
- EncryptedPackage.cs
- Quaternion.cs
- PropertyTab.cs
- DataGridViewColumn.cs
- RTTrackingProfile.cs
- DBCSCodePageEncoding.cs
- MenuCommand.cs
- XmlSerializationWriter.cs
- CapabilitiesAssignment.cs
- Renderer.cs
- LinqDataSourceDisposeEventArgs.cs
- XNodeValidator.cs
- SecurityKeyIdentifierClause.cs
- CallbackHandler.cs
- CompilationSection.cs
- ExpressionVisitorHelpers.cs
- NameObjectCollectionBase.cs
- IsolatedStorageException.cs
- XmlDictionaryReaderQuotas.cs
- StandardOleMarshalObject.cs
- SubpageParaClient.cs
- TimeSpanValidator.cs
- HttpProfileBase.cs
- SmtpDigestAuthenticationModule.cs
- ProcessStartInfo.cs
- TextParaLineResult.cs
- CodeTypeReferenceCollection.cs
- AddressingProperty.cs
- DecoderBestFitFallback.cs
- SuppressMessageAttribute.cs
- EffectiveValueEntry.cs
- TreeViewImageKeyConverter.cs
- TraceHandlerErrorFormatter.cs
- CodeAttributeDeclarationCollection.cs
- processwaithandle.cs
- IntPtr.cs
- GenericWebPart.cs
- FreezableCollection.cs
- ConnectionInterfaceCollection.cs
- Style.cs
- MouseCaptureWithinProperty.cs
- DependsOnAttribute.cs
- Marshal.cs
- GPPOINTF.cs
- SendingRequestEventArgs.cs
- DesignerToolboxInfo.cs
- SqlNotificationRequest.cs