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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- SqlDataSourceCommandEventArgs.cs
- sortedlist.cs
- DataGridViewEditingControlShowingEventArgs.cs
- WmiPutTraceRecord.cs
- UnsafeNativeMethods.cs
- StoreItemCollection.Loader.cs
- ControlPropertyNameConverter.cs
- Container.cs
- CriticalHandle.cs
- AttachmentService.cs
- WebScriptMetadataMessageEncoderFactory.cs
- Odbc32.cs
- OleDbFactory.cs
- UpdateException.cs
- WebPartPersonalization.cs
- QueryContinueDragEvent.cs
- PolicyImporterElement.cs
- SecurityToken.cs
- ButtonPopupAdapter.cs
- Control.cs
- MultiAsyncResult.cs
- Double.cs
- RightsManagementEncryptedStream.cs
- TypeBrowserDialog.cs
- TrueReadOnlyCollection.cs
- DataListAutoFormat.cs
- ProjectionNode.cs
- QueryCacheKey.cs
- GridViewEditEventArgs.cs
- SoapWriter.cs
- EntityDataSourceWizardForm.cs
- RegisteredArrayDeclaration.cs
- TrackingRecordPreFilter.cs
- ActivityBuilderXamlWriter.cs
- SctClaimSerializer.cs
- StrokeIntersection.cs
- FontNameConverter.cs
- Internal.cs
- UnsafeNativeMethodsCLR.cs
- TagPrefixAttribute.cs
- Path.cs
- Stylesheet.cs
- ObjectNotFoundException.cs
- MutexSecurity.cs
- LinqToSqlWrapper.cs
- Accessible.cs
- XmlUtf8RawTextWriter.cs
- SystemIPGlobalStatistics.cs
- hresults.cs
- InstanceHandleReference.cs
- SurrogateEncoder.cs
- XmlSchemaComplexContent.cs
- HWStack.cs
- SafeCertificateStore.cs
- ConditionCollection.cs
- FileNotFoundException.cs
- SR.cs
- ProvidePropertyAttribute.cs
- ThreadStartException.cs
- RtfControls.cs
- ArcSegment.cs
- Process.cs
- WebScriptMetadataFormatter.cs
- StructuralCache.cs
- FileBasedResourceGroveler.cs
- BaseCodeDomTreeGenerator.cs
- RankException.cs
- AQNBuilder.cs
- XmlSchemaObjectTable.cs
- UserNameSecurityToken.cs
- ServiceTimeoutsElement.cs
- DataGridRow.cs
- FloaterBaseParagraph.cs
- ArrayWithOffset.cs
- MonthChangedEventArgs.cs
- TaskFormBase.cs
- HttpServerProtocol.cs
- RootBrowserWindowAutomationPeer.cs
- LineGeometry.cs
- Decoder.cs
- NumberFormatInfo.cs
- XmlIncludeAttribute.cs
- SmtpFailedRecipientsException.cs
- CookieHandler.cs
- ProcessManager.cs
- CompModSwitches.cs
- WeakEventManager.cs
- MarkupObject.cs
- Model3D.cs
- ConsumerConnectionPoint.cs
- DataGridViewHitTestInfo.cs
- SupportingTokenSecurityTokenResolver.cs
- InstallerTypeAttribute.cs
- CustomCategoryAttribute.cs
- EllipseGeometry.cs
- HashHelper.cs
- DiagnosticsElement.cs
- SqlDataSourceEnumerator.cs
- CopyAttributesAction.cs