Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- WebPartConnectionCollection.cs
- ConfigurationException.cs
- PanelDesigner.cs
- ToolStripSplitStackLayout.cs
- AssociationType.cs
- ListControlActionList.cs
- SmiEventSink_DeferedProcessing.cs
- ApplicationTrust.cs
- GlyphInfoList.cs
- SecureEnvironment.cs
- DataBoundControlAdapter.cs
- Point4DValueSerializer.cs
- BooleanStorage.cs
- Int32Storage.cs
- QualifiedCellIdBoolean.cs
- COM2PropertyPageUITypeConverter.cs
- ValidatorCollection.cs
- GridViewItemAutomationPeer.cs
- Config.cs
- FormsAuthenticationUser.cs
- AudioLevelUpdatedEventArgs.cs
- Activator.cs
- SqlDataSourceSelectingEventArgs.cs
- TwoPhaseCommit.cs
- PageTheme.cs
- DrawTreeNodeEventArgs.cs
- TransformerTypeCollection.cs
- SizeAnimationBase.cs
- XsltInput.cs
- metadatamappinghashervisitor.hashsourcebuilder.cs
- SymmetricAlgorithm.cs
- CommentEmitter.cs
- HtmlImage.cs
- CompositeFontParser.cs
- ValueType.cs
- PackageProperties.cs
- uribuilder.cs
- ColumnResult.cs
- WindowInteropHelper.cs
- LinkedResourceCollection.cs
- ServiceOperationParameter.cs
- HttpWriter.cs
- DataGridViewBand.cs
- EvidenceBase.cs
- EdmError.cs
- InternalResources.cs
- FontStyles.cs
- CqlParserHelpers.cs
- MessageDecoder.cs
- ToolBarButton.cs
- HMACSHA512.cs
- SingleQueryOperator.cs
- BindingManagerDataErrorEventArgs.cs
- Section.cs
- AffineTransform3D.cs
- XmlElementList.cs
- DbInsertCommandTree.cs
- ApplicationActivator.cs
- DataGridCellAutomationPeer.cs
- FileUtil.cs
- SizeChangedInfo.cs
- TextTreeInsertElementUndoUnit.cs
- ToolStripHighContrastRenderer.cs
- Stroke.cs
- DataStorage.cs
- Vector3D.cs
- X509CertificateInitiatorServiceCredential.cs
- GridViewItemAutomationPeer.cs
- ArraySortHelper.cs
- MouseButtonEventArgs.cs
- TraceUtils.cs
- ExpressionReplacer.cs
- CodeIdentifier.cs
- SoapIncludeAttribute.cs
- NotSupportedException.cs
- DelegatingMessage.cs
- CapiNative.cs
- EntityViewGenerationAttribute.cs
- CompositeFontInfo.cs
- ByteRangeDownloader.cs
- SizeAnimation.cs
- TypeUnloadedException.cs
- ArgumentException.cs
- TextEndOfLine.cs
- CheckBoxAutomationPeer.cs
- MimeTypeMapper.cs
- XmlCharacterData.cs
- BitmapEffect.cs
- HttpModuleActionCollection.cs
- CreateInstanceBinder.cs
- PathFigureCollectionConverter.cs
- SmtpCommands.cs
- StreamGeometryContext.cs
- Base64Decoder.cs
- WebConfigurationManager.cs
- TextRangeEdit.cs
- IResourceProvider.cs
- DataControlImageButton.cs
- TextParagraphProperties.cs
- DataGridViewColumnHeaderCell.cs