Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- OrderPreservingPipeliningSpoolingTask.cs
- SecurityValidationBehavior.cs
- BooleanSwitch.cs
- COM2ExtendedUITypeEditor.cs
- EventSource.cs
- securitymgrsite.cs
- PrintDialogException.cs
- TransactionScope.cs
- UpdateCompiler.cs
- SoapMessage.cs
- SafeSecurityHandles.cs
- CustomAttributeBuilder.cs
- RuleEngine.cs
- LiteralLink.cs
- FastEncoderWindow.cs
- PackageProperties.cs
- RemotingConfiguration.cs
- XsdBuildProvider.cs
- CalendarAutoFormatDialog.cs
- FileChangesMonitor.cs
- TextTreeExtractElementUndoUnit.cs
- NativeDirectoryServicesQueryAPIs.cs
- WebPartCancelEventArgs.cs
- ImageCodecInfo.cs
- CodeFieldReferenceExpression.cs
- RetrieveVirtualItemEventArgs.cs
- Int64KeyFrameCollection.cs
- ScriptDescriptor.cs
- ConfigurationValue.cs
- DataListCommandEventArgs.cs
- StyleTypedPropertyAttribute.cs
- XmlDataDocument.cs
- WebEventCodes.cs
- FrameworkRichTextComposition.cs
- QueryOutputWriter.cs
- HotSpotCollection.cs
- RegexBoyerMoore.cs
- HttpCapabilitiesEvaluator.cs
- XPathParser.cs
- FormsAuthenticationEventArgs.cs
- KeyInfo.cs
- EntityConnectionStringBuilder.cs
- TrackBar.cs
- InvokeHandlers.cs
- TextRunTypographyProperties.cs
- HttpApplication.cs
- SymmetricKeyWrap.cs
- TypeCodeDomSerializer.cs
- WebPartCollection.cs
- DateTimeStorage.cs
- XmlDataCollection.cs
- OletxResourceManager.cs
- SchemaImporterExtensionElement.cs
- GridErrorDlg.cs
- StorageScalarPropertyMapping.cs
- Message.cs
- SafeNativeMethodsCLR.cs
- FunctionParameter.cs
- ParameterCollection.cs
- XamlSerializerUtil.cs
- XPathSelectionIterator.cs
- DesignerObject.cs
- ConfigurationPropertyCollection.cs
- AnimatedTypeHelpers.cs
- DebugView.cs
- Task.cs
- Misc.cs
- XamlWriter.cs
- ResourceIDHelper.cs
- XmlDataLoader.cs
- TrackBarRenderer.cs
- ArrayConverter.cs
- ManipulationInertiaStartingEventArgs.cs
- HeaderedItemsControl.cs
- NullableDecimalMinMaxAggregationOperator.cs
- SystemWebSectionGroup.cs
- RowUpdatingEventArgs.cs
- PostBackTrigger.cs
- InstanceLockQueryResult.cs
- XmlSubtreeReader.cs
- StylusPointPropertyInfo.cs
- NameValueFileSectionHandler.cs
- XmlTypeAttribute.cs
- ColorTransformHelper.cs
- ModuleBuilder.cs
- ProviderBase.cs
- Blend.cs
- MetadataStore.cs
- dbenumerator.cs
- Binding.cs
- PropertyEmitterBase.cs
- PropertyPathWorker.cs
- CodeDelegateInvokeExpression.cs
- MatrixTransform3D.cs
- IncrementalReadDecoders.cs
- OrderByBuilder.cs
- BamlRecordHelper.cs
- UiaCoreApi.cs
- COM2Properties.cs
- AddInSegmentDirectoryNotFoundException.cs