Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebControls / Substitution.cs / 1305376 / 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), ] 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), ] 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
- FormsAuthenticationEventArgs.cs
- SQLMoneyStorage.cs
- UnitySerializationHolder.cs
- SpeechSeg.cs
- XmlEventCache.cs
- VirtualizingPanel.cs
- RNGCryptoServiceProvider.cs
- DesignTimeTemplateParser.cs
- ServicesUtilities.cs
- PageAdapter.cs
- GeometryCombineModeValidation.cs
- InvalidComObjectException.cs
- SafeLocalMemHandle.cs
- DoubleLink.cs
- WebPartEditVerb.cs
- HScrollBar.cs
- ColorKeyFrameCollection.cs
- BamlLocalizer.cs
- SessionPageStateSection.cs
- SessionParameter.cs
- RelatedPropertyManager.cs
- CodeAccessPermission.cs
- BevelBitmapEffect.cs
- ChangeToolStripParentVerb.cs
- KnownColorTable.cs
- FileSystemWatcher.cs
- HtmlValidationSummaryAdapter.cs
- PersonalizableTypeEntry.cs
- Formatter.cs
- WebPartCollection.cs
- WorkflowOperationFault.cs
- HttpHandlersSection.cs
- Int32RectValueSerializer.cs
- Automation.cs
- XmlJsonReader.cs
- OrderablePartitioner.cs
- InternalsVisibleToAttribute.cs
- FatalException.cs
- ToolStripSeparator.cs
- SAPIEngineTypes.cs
- OutputScopeManager.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- ConfigXmlText.cs
- EntityType.cs
- GroupItem.cs
- QilPatternVisitor.cs
- PrintEvent.cs
- GenericEnumConverter.cs
- CollectionType.cs
- SystemFonts.cs
- LineServicesRun.cs
- BrowserDefinition.cs
- SelectionProviderWrapper.cs
- COSERVERINFO.cs
- ADMembershipProvider.cs
- TextMarkerSource.cs
- TextTabProperties.cs
- SchemaImporterExtensionsSection.cs
- ConsoleCancelEventArgs.cs
- XmlBinaryWriter.cs
- WindowsHyperlink.cs
- XPathScanner.cs
- CurrencyManager.cs
- BufferedGraphics.cs
- RadialGradientBrush.cs
- SequenceDesigner.cs
- CustomCredentialPolicy.cs
- CompositeDataBoundControl.cs
- WebPartUserCapability.cs
- EncryptedXml.cs
- ItemCollection.cs
- PersonalizationProviderHelper.cs
- ResXDataNode.cs
- QEncodedStream.cs
- XmlDownloadManager.cs
- GridViewDeleteEventArgs.cs
- querybuilder.cs
- PeerResolverSettings.cs
- CompensationDesigner.cs
- UriExt.cs
- WebPartHeaderCloseVerb.cs
- FromReply.cs
- MessageQueuePermissionEntryCollection.cs
- DataBindingHandlerAttribute.cs
- OpCopier.cs
- MethodImplAttribute.cs
- XhtmlConformanceSection.cs
- RSAPKCS1SignatureFormatter.cs
- SqlUserDefinedAggregateAttribute.cs
- ShapingEngine.cs
- IsolatedStoragePermission.cs
- DataSourceXmlAttributeAttribute.cs
- XmlCharCheckingReader.cs
- _UriTypeConverter.cs
- FileSystemWatcher.cs
- LinkButton.cs
- FrameworkReadOnlyPropertyMetadata.cs
- DelegatingTypeDescriptionProvider.cs
- ToolboxControl.cs
- CustomExpression.cs