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
- SqlException.cs
- StringReader.cs
- MSG.cs
- ButtonChrome.cs
- TextParagraphView.cs
- CodeArgumentReferenceExpression.cs
- ExtensionWindowResizeGrip.cs
- SqlCacheDependencyDatabase.cs
- CatchBlock.cs
- SerializeAbsoluteContext.cs
- BeginStoryboard.cs
- UnknownMessageReceivedEventArgs.cs
- ExpressionConverter.cs
- ConstructorExpr.cs
- Activator.cs
- DataRecordInternal.cs
- TaskFactory.cs
- ProgressBar.cs
- CatalogPartChrome.cs
- TableLayoutPanelCellPosition.cs
- XhtmlBasicCommandAdapter.cs
- AdRotator.cs
- WMICapabilities.cs
- FixUpCollection.cs
- DefaultValueAttribute.cs
- HelpFileFileNameEditor.cs
- EntityCommandExecutionException.cs
- CheckedPointers.cs
- XmlText.cs
- MimeTypePropertyAttribute.cs
- DataServiceQueryContinuation.cs
- ContextToken.cs
- CollectionCodeDomSerializer.cs
- OracleEncoding.cs
- SqlMetaData.cs
- TreeViewItemAutomationPeer.cs
- Clipboard.cs
- SqlDataSourceWizardForm.cs
- Point3DCollection.cs
- DependencyPropertyDescriptor.cs
- RIPEMD160.cs
- TraceFilter.cs
- TransactedBatchContext.cs
- CompletionProxy.cs
- TagPrefixAttribute.cs
- ComponentGuaranteesAttribute.cs
- ThicknessConverter.cs
- ProxyWebPartConnectionCollection.cs
- recordstatefactory.cs
- CacheOutputQuery.cs
- SafeSecurityHandles.cs
- ByteStreamMessageEncodingElement.cs
- HttpClientCertificate.cs
- CodeGotoStatement.cs
- XDRSchema.cs
- DiscoveryServiceExtension.cs
- WebPartDeleteVerb.cs
- OverrideMode.cs
- SoapTypeAttribute.cs
- GraphicsContainer.cs
- ValidationSummary.cs
- SHA256.cs
- HttpHostedTransportConfiguration.cs
- RegistrationServices.cs
- EdgeModeValidation.cs
- FontWeightConverter.cs
- ImageConverter.cs
- OSFeature.cs
- ExtendedTransformFactory.cs
- WindowsProgressbar.cs
- GlyphingCache.cs
- UserUseLicenseDictionaryLoader.cs
- WindowsTab.cs
- BitmapFrameEncode.cs
- Border.cs
- EntityStoreSchemaGenerator.cs
- COM2IDispatchConverter.cs
- LightweightEntityWrapper.cs
- MenuItemAutomationPeer.cs
- BufferManager.cs
- SamlSecurityToken.cs
- ExtractCollection.cs
- CharEnumerator.cs
- BoundColumn.cs
- HtmlInputSubmit.cs
- DefaultPrintController.cs
- PinnedBufferMemoryStream.cs
- EventMetadata.cs
- ExpressionPrinter.cs
- Environment.cs
- IDReferencePropertyAttribute.cs
- ProfileModule.cs
- SecurityHelper.cs
- ProcessModule.cs
- LayoutEditorPart.cs
- DependencyPropertyHelper.cs
- TextParagraphProperties.cs
- ElementNotAvailableException.cs
- VectorCollectionConverter.cs
- Utils.cs