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
- panel.cs
- SimpleLine.cs
- DataStreams.cs
- RepeaterItemCollection.cs
- XsltFunctions.cs
- CustomAttribute.cs
- EdmPropertyAttribute.cs
- EntityPropertyMappingAttribute.cs
- DataRelationCollection.cs
- ImageSource.cs
- RectIndependentAnimationStorage.cs
- ProvideValueServiceProvider.cs
- StyleBamlTreeBuilder.cs
- SystemIPv4InterfaceProperties.cs
- AnimationTimeline.cs
- DiagnosticsElement.cs
- MenuItemStyle.cs
- XmlNamespaceManager.cs
- SystemNetworkInterface.cs
- ErrorHandler.cs
- MergablePropertyAttribute.cs
- _SslStream.cs
- StrongNamePublicKeyBlob.cs
- ArcSegment.cs
- XPathBinder.cs
- DefaultValueConverter.cs
- DomainConstraint.cs
- FixedSOMTextRun.cs
- TextRangeEditLists.cs
- RotateTransform.cs
- UserControlAutomationPeer.cs
- WebPartDisplayModeCollection.cs
- Comparer.cs
- SmtpException.cs
- SqlGatherConsumedAliases.cs
- MappingItemCollection.cs
- FixUpCollection.cs
- Run.cs
- MenuStrip.cs
- MissingMethodException.cs
- DependencyPropertyKey.cs
- XmlNamedNodeMap.cs
- PerfProviderCollection.cs
- Activator.cs
- Calendar.cs
- WpfWebRequestHelper.cs
- ThreadWorkerController.cs
- PropertiesTab.cs
- CodeCastExpression.cs
- ObjectDataSourceEventArgs.cs
- DataControlPagerLinkButton.cs
- EventLogTraceListener.cs
- oledbmetadatacollectionnames.cs
- ResourcePermissionBase.cs
- CorrelationManager.cs
- DefaultTextStoreTextComposition.cs
- CurrencyManager.cs
- EdmItemCollection.OcAssemblyCache.cs
- Span.cs
- FileDialog.cs
- ArgumentOutOfRangeException.cs
- FillErrorEventArgs.cs
- GeneralTransformCollection.cs
- StateMachineSubscription.cs
- ProcessModelInfo.cs
- StringResourceManager.cs
- StringPropertyBuilder.cs
- UrlAuthFailedErrorFormatter.cs
- mediaclock.cs
- cookieexception.cs
- VisualBrush.cs
- SemaphoreFullException.cs
- ObjectSerializerFactory.cs
- ConfigXmlElement.cs
- ComponentDispatcherThread.cs
- RenamedEventArgs.cs
- BridgeDataReader.cs
- NavigateEvent.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- MimeReflector.cs
- XmlValidatingReader.cs
- DoubleAnimation.cs
- Attributes.cs
- CallbackException.cs
- DisplayMemberTemplateSelector.cs
- IgnoreFileBuildProvider.cs
- HScrollProperties.cs
- OleStrCAMarshaler.cs
- XmlSchemaSimpleContentRestriction.cs
- SqlTrackingService.cs
- DuplicateWaitObjectException.cs
- Matrix3DConverter.cs
- XDRSchema.cs
- DataGridViewCellConverter.cs
- DbTypeMap.cs
- OperatingSystem.cs
- RectAnimation.cs
- OptionUsage.cs
- SynchronizationContext.cs
- MobileControlsSectionHandler.cs