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
- GPPOINT.cs
- HtmlContainerControl.cs
- XmlSchemaCollection.cs
- AutomationProperty.cs
- _HTTPDateParse.cs
- SubMenuStyleCollection.cs
- oledbconnectionstring.cs
- _HelperAsyncResults.cs
- AlphabeticalEnumConverter.cs
- TrackingMemoryStream.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- Hyperlink.cs
- HostedHttpTransportManager.cs
- PermissionAttributes.cs
- BitmapEffectInput.cs
- ConnectionPoint.cs
- Compiler.cs
- InheritanceUI.cs
- ProxyHwnd.cs
- WebDescriptionAttribute.cs
- mactripleDES.cs
- SafeLocalMemHandle.cs
- TransferMode.cs
- dbenumerator.cs
- WindowInteractionStateTracker.cs
- ClientConvert.cs
- MsmqDiagnostics.cs
- SqlFunctionAttribute.cs
- SharedStream.cs
- UrlAuthorizationModule.cs
- MatrixTransform3D.cs
- SelectionService.cs
- messageonlyhwndwrapper.cs
- WebControlAdapter.cs
- ToolboxService.cs
- entityreference_tresulttype.cs
- Gdiplus.cs
- WebPartExportVerb.cs
- FixedFlowMap.cs
- GacUtil.cs
- SHA256Managed.cs
- Point.cs
- RankException.cs
- OdbcRowUpdatingEvent.cs
- Token.cs
- DrawListViewItemEventArgs.cs
- VideoDrawing.cs
- BitmapScalingModeValidation.cs
- ConsoleKeyInfo.cs
- TypeReference.cs
- PasswordTextContainer.cs
- GeometryHitTestParameters.cs
- PropertyInfoSet.cs
- ConstNode.cs
- PeerNodeTraceRecord.cs
- CipherData.cs
- BaseCollection.cs
- OdbcConnectionStringbuilder.cs
- AudioStateChangedEventArgs.cs
- ToolStripControlHost.cs
- baseaxisquery.cs
- PageHandlerFactory.cs
- UserPersonalizationStateInfo.cs
- UpdateProgress.cs
- SqlNodeAnnotation.cs
- ControlCollection.cs
- WinFormsComponentEditor.cs
- DataPagerFieldCommandEventArgs.cs
- PropertyEmitter.cs
- Point4D.cs
- LinkConverter.cs
- ProviderException.cs
- GroupLabel.cs
- GraphicsContext.cs
- PropertiesTab.cs
- XmlParser.cs
- XmlValidatingReader.cs
- ComponentChangingEvent.cs
- ToolZone.cs
- XPathNodeHelper.cs
- LinkTarget.cs
- SafeProcessHandle.cs
- WaitHandle.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- ComponentCache.cs
- linebase.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- Regex.cs
- XmlWrappingReader.cs
- OracleString.cs
- DelegateBodyWriter.cs
- HttpInputStream.cs
- BehaviorEditorPart.cs
- securestring.cs
- ButtonChrome.cs
- MsdtcClusterUtils.cs
- ConfigurationSettings.cs
- SynchronizedInputPattern.cs
- FixedTextView.cs
- Color.cs