Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- StateMachine.cs
- Property.cs
- BuildProvider.cs
- BooleanStorage.cs
- LineGeometry.cs
- StoragePropertyMapping.cs
- XamlTypeMapper.cs
- Binding.cs
- EFColumnProvider.cs
- FormViewInsertedEventArgs.cs
- ExpressionBuilder.cs
- TemplateComponentConnector.cs
- CrossContextChannel.cs
- Int64KeyFrameCollection.cs
- linebase.cs
- DataGridViewComboBoxColumn.cs
- HijriCalendar.cs
- QilName.cs
- PageCache.cs
- indexingfiltermarshaler.cs
- PartialToken.cs
- ColorBuilder.cs
- FileLogRecordStream.cs
- ObjectDataSourceSelectingEventArgs.cs
- SimpleMailWebEventProvider.cs
- CodeGroup.cs
- ComPlusServiceLoader.cs
- Util.cs
- CompilationRelaxations.cs
- TableAdapterManagerHelper.cs
- MimeObjectFactory.cs
- ValuePatternIdentifiers.cs
- InternalUserCancelledException.cs
- SynthesizerStateChangedEventArgs.cs
- InternalSafeNativeMethods.cs
- ExpressionTextBoxAutomationPeer.cs
- Int32CAMarshaler.cs
- File.cs
- ThumbAutomationPeer.cs
- DataBindingList.cs
- GlyphsSerializer.cs
- DBAsyncResult.cs
- TableSectionStyle.cs
- bidPrivateBase.cs
- RedirectionProxy.cs
- BaseAddressPrefixFilterElementCollection.cs
- SystemFonts.cs
- LogExtentCollection.cs
- GroupItemAutomationPeer.cs
- ContentIterators.cs
- Processor.cs
- Validator.cs
- COM2Properties.cs
- UriExt.cs
- SystemIPGlobalStatistics.cs
- XamlPointCollectionSerializer.cs
- CommandManager.cs
- ConnectionsZone.cs
- WebPartDisplayModeCollection.cs
- VSDExceptions.cs
- HttpAsyncResult.cs
- FormViewUpdateEventArgs.cs
- Rotation3D.cs
- Transform.cs
- BuiltInExpr.cs
- SqlDataSourceCache.cs
- StaticContext.cs
- EventManager.cs
- FontDifferentiator.cs
- BasicCellRelation.cs
- HttpStreamFormatter.cs
- EmptyCollection.cs
- CustomAttributeFormatException.cs
- EventProvider.cs
- SimpleLine.cs
- _ConnectOverlappedAsyncResult.cs
- SqlDataSourceQuery.cs
- SqlTypeConverter.cs
- MobileControlsSectionHandler.cs
- XmlPreloadedResolver.cs
- SrgsElementList.cs
- _AutoWebProxyScriptEngine.cs
- IteratorFilter.cs
- RowsCopiedEventArgs.cs
- COM2ComponentEditor.cs
- SQLByte.cs
- TransformedBitmap.cs
- ResXResourceWriter.cs
- Point3D.cs
- HttpStaticObjectsCollectionBase.cs
- SafeThemeHandle.cs
- ApplicationServicesHostFactory.cs
- RemoteWebConfigurationHost.cs
- ConvertersCollection.cs
- BypassElement.cs
- WeakRefEnumerator.cs
- DiagnosticsConfigurationHandler.cs
- DataRecord.cs
- HtmlTable.cs
- XmlAggregates.cs