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
- ObfuscationAttribute.cs
- xsdvalidator.cs
- SystemUnicastIPAddressInformation.cs
- TargetConverter.cs
- CqlBlock.cs
- EventManager.cs
- FixedDocumentSequencePaginator.cs
- FactoryId.cs
- HGlobalSafeHandle.cs
- DataContext.cs
- SamlAssertion.cs
- FileUtil.cs
- HTTPNotFoundHandler.cs
- ValidationVisibilityAttribute.cs
- RowParagraph.cs
- MissingMethodException.cs
- Normalizer.cs
- DnsPermission.cs
- WindowPattern.cs
- Expander.cs
- SelectionListDesigner.cs
- InlineCategoriesDocument.cs
- FormsAuthenticationUser.cs
- EnterpriseServicesHelper.cs
- ProviderUtil.cs
- BreakRecordTable.cs
- WebServicesSection.cs
- PointLightBase.cs
- ColorBlend.cs
- ReaderWriterLockWrapper.cs
- MemberCollection.cs
- SmiTypedGetterSetter.cs
- NullableBoolConverter.cs
- AmbiguousMatchException.cs
- TemplateContentLoader.cs
- ProjectionCamera.cs
- AsyncOperation.cs
- NetNamedPipeBindingElement.cs
- OdbcUtils.cs
- SemanticResolver.cs
- SecurityDocument.cs
- ResourceCategoryAttribute.cs
- Events.cs
- ImageDrawing.cs
- MiniParameterInfo.cs
- RightsManagementEncryptedStream.cs
- WinCategoryAttribute.cs
- WindowsGraphics2.cs
- XmlLoader.cs
- RawStylusActions.cs
- BindingListCollectionView.cs
- PointConverter.cs
- Point3DValueSerializer.cs
- httpserverutility.cs
- TableLayoutStyleCollection.cs
- MarshalByRefObject.cs
- AttachedPropertyMethodSelector.cs
- DeflateStream.cs
- ToolBarPanel.cs
- Models.cs
- MD5.cs
- ScrollEvent.cs
- FileRecordSequenceCompletedAsyncResult.cs
- CompatibleComparer.cs
- UserControlAutomationPeer.cs
- BinaryMessageFormatter.cs
- MetadataPropertyCollection.cs
- CodeThrowExceptionStatement.cs
- NTAccount.cs
- XmlTextWriter.cs
- WebHeaderCollection.cs
- TypeExtensions.cs
- CodeNamespaceImport.cs
- SoapObjectWriter.cs
- FormClosingEvent.cs
- Tuple.cs
- HierarchicalDataSourceControl.cs
- SqlDelegatedTransaction.cs
- HttpContextWrapper.cs
- Error.cs
- dataprotectionpermission.cs
- RawTextInputReport.cs
- ValidationError.cs
- TextOptionsInternal.cs
- Roles.cs
- HostingEnvironmentSection.cs
- InvokeMethodActivity.cs
- ExpandCollapsePattern.cs
- SequenceFullException.cs
- Translator.cs
- PauseStoryboard.cs
- XmlSchemaDatatype.cs
- EncryptedPackage.cs
- SqlGatherConsumedAliases.cs
- EnumBuilder.cs
- NavigationExpr.cs
- RulePatternOps.cs
- ClientBuildManagerTypeDescriptionProviderBridge.cs
- BuildProvider.cs
- ExeConfigurationFileMap.cs