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
- Rotation3D.cs
- CodeRegionDirective.cs
- CollectionBuilder.cs
- XamlNamespaceHelper.cs
- XhtmlMobileTextWriter.cs
- OdbcPermission.cs
- BookmarkUndoUnit.cs
- XmlSchemaElement.cs
- SqlFacetAttribute.cs
- MobileListItemCollection.cs
- VectorKeyFrameCollection.cs
- FormatterConverter.cs
- ToolboxItem.cs
- MetadataHelper.cs
- ISO2022Encoding.cs
- TraceEventCache.cs
- ArrayWithOffset.cs
- sqlnorm.cs
- TraceLog.cs
- RawStylusInputCustomDataList.cs
- ConfigurationValidatorAttribute.cs
- WindowsGraphics2.cs
- KeyedCollection.cs
- StatusBarPanelClickEvent.cs
- QuaternionAnimation.cs
- DoubleLinkListEnumerator.cs
- ExpressionBuilder.cs
- WinFormsUtils.cs
- DelegateSerializationHolder.cs
- SchemaObjectWriter.cs
- CreateRefExpr.cs
- PictureBoxDesigner.cs
- FormViewPageEventArgs.cs
- Thread.cs
- FlagsAttribute.cs
- XmlDeclaration.cs
- PrimaryKeyTypeConverter.cs
- DataTableClearEvent.cs
- CodeDelegateInvokeExpression.cs
- ThicknessAnimation.cs
- BamlCollectionHolder.cs
- FindCriteriaApril2005.cs
- Material.cs
- WebPartAuthorizationEventArgs.cs
- CanonicalizationDriver.cs
- ObjectDataSourceMethodEventArgs.cs
- TextTrailingCharacterEllipsis.cs
- Point4D.cs
- WebReference.cs
- HostProtectionException.cs
- RadioButton.cs
- XmlSerializerFactory.cs
- ParserContext.cs
- ColorEditor.cs
- BitmapEffect.cs
- DescendentsWalkerBase.cs
- DocumentSequence.cs
- TheQuery.cs
- DateTimeFormatInfo.cs
- DefaultWorkflowLoaderService.cs
- TextServicesCompartment.cs
- DashStyle.cs
- PrefixHandle.cs
- ThemeDirectoryCompiler.cs
- BaseDataListDesigner.cs
- ScriptingProfileServiceSection.cs
- FilterQueryOptionExpression.cs
- AccessText.cs
- ReaderWriterLock.cs
- Preprocessor.cs
- DataControlLinkButton.cs
- KeysConverter.cs
- ButtonFieldBase.cs
- StylusPointPropertyUnit.cs
- TextEditorTables.cs
- BuildProviderCollection.cs
- AttributeEmitter.cs
- XpsFilter.cs
- CompareInfo.cs
- SHA512.cs
- _SslState.cs
- ConfigXmlWhitespace.cs
- ConnectionPoolRegistry.cs
- CheckBoxList.cs
- StringComparer.cs
- EndpointBehaviorElement.cs
- DefaultProxySection.cs
- DynamicResourceExtensionConverter.cs
- LogExtentCollection.cs
- TempFiles.cs
- CommonObjectSecurity.cs
- TemplateBuilder.cs
- ConfigurationLocation.cs
- MsmqIntegrationElement.cs
- InkCanvasSelectionAdorner.cs
- _RequestCacheProtocol.cs
- StylusPointDescription.cs
- FormatterServices.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- DynamicRenderer.cs