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
- COAUTHIDENTITY.cs
- HttpRuntime.cs
- BamlWriter.cs
- DbConnectionPool.cs
- FilterQuery.cs
- BitmapEffectDrawing.cs
- PropagatorResult.cs
- MatrixAnimationUsingPath.cs
- DataList.cs
- GenericsInstances.cs
- RawUIStateInputReport.cs
- Scripts.cs
- MetabaseReader.cs
- DrawingVisual.cs
- Timer.cs
- RectangleConverter.cs
- Query.cs
- TypefaceCollection.cs
- ToggleProviderWrapper.cs
- ArglessEventHandlerProxy.cs
- TranslateTransform.cs
- UniqueEventHelper.cs
- TypeLoadException.cs
- PropertyDescriptors.cs
- CancellationToken.cs
- SchemaImporterExtensionsSection.cs
- ToolBar.cs
- BamlBinaryReader.cs
- SymDocumentType.cs
- SmiTypedGetterSetter.cs
- srgsitem.cs
- SessionIDManager.cs
- RecognizerStateChangedEventArgs.cs
- SubMenuStyle.cs
- FixedSOMSemanticBox.cs
- SID.cs
- DependencyProperty.cs
- TransformCollection.cs
- WorkItem.cs
- RangeValueProviderWrapper.cs
- WebPartTransformerCollection.cs
- CodeTypeReferenceCollection.cs
- CodeExporter.cs
- SetStoryboardSpeedRatio.cs
- HttpContextServiceHost.cs
- DataBoundLiteralControl.cs
- Timer.cs
- DataSourceDesigner.cs
- MetadataCache.cs
- RenderOptions.cs
- EntityViewGenerationAttribute.cs
- MissingSatelliteAssemblyException.cs
- OpenTypeLayoutCache.cs
- IntegerValidatorAttribute.cs
- ConfigXmlDocument.cs
- ClientSettingsSection.cs
- FrameworkTextComposition.cs
- CapabilitiesState.cs
- TreeNode.cs
- CommonDialog.cs
- DataGridViewDataErrorEventArgs.cs
- SectionUpdates.cs
- Mouse.cs
- PointConverter.cs
- TypeDelegator.cs
- ellipse.cs
- MobileContainerDesigner.cs
- RegexTree.cs
- DataGridRow.cs
- BitmapEffectGroup.cs
- WSFederationHttpBindingElement.cs
- SqlXml.cs
- KoreanLunisolarCalendar.cs
- ClosureBinding.cs
- TextProperties.cs
- DetailsViewInsertedEventArgs.cs
- CodeCommentStatementCollection.cs
- Pkcs9Attribute.cs
- ColorConverter.cs
- QueryGenerator.cs
- LineServices.cs
- MasterPageParser.cs
- UserNameSecurityTokenProvider.cs
- InstanceHandleConflictException.cs
- Quad.cs
- IgnoreFileBuildProvider.cs
- PrefixQName.cs
- Binding.cs
- CodeBlockBuilder.cs
- DataTable.cs
- SecurityRuntime.cs
- SizeAnimation.cs
- MenuItemBinding.cs
- Transform.cs
- SimpleRecyclingCache.cs
- TextProperties.cs
- StylusCollection.cs
- AuthenticationService.cs
- EntityDataSourceDesignerHelper.cs
- ResolvedKeyFrameEntry.cs