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
- JavaScriptSerializer.cs
- ViewBase.cs
- PeerNameRecord.cs
- SocketException.cs
- MethodBody.cs
- InvariantComparer.cs
- XPathItem.cs
- ComboBoxRenderer.cs
- PointKeyFrameCollection.cs
- Logging.cs
- DataGridViewControlCollection.cs
- COM2PropertyDescriptor.cs
- AtomParser.cs
- DomainUpDown.cs
- FrameworkReadOnlyPropertyMetadata.cs
- DesignerHelpers.cs
- SqlStatistics.cs
- HostedTransportConfigurationManager.cs
- XmlChildNodes.cs
- DynamicRenderer.cs
- DetailsViewInsertedEventArgs.cs
- HtmlTable.cs
- CalendarDateRangeChangingEventArgs.cs
- TogglePattern.cs
- MessageQueue.cs
- Base64Encoder.cs
- EventLogHandle.cs
- BitmapImage.cs
- SignatureResourceHelper.cs
- codemethodreferenceexpression.cs
- HtmlCommandAdapter.cs
- TextTrailingWordEllipsis.cs
- BackgroundFormatInfo.cs
- BrushProxy.cs
- IsolatedStorageSecurityState.cs
- DBSqlParser.cs
- ListMarkerSourceInfo.cs
- WorkflowDurableInstance.cs
- HtmlMobileTextWriter.cs
- metadatamappinghashervisitor.cs
- MsmqMessageProperty.cs
- GrammarBuilderBase.cs
- PreservationFileWriter.cs
- TabletDeviceInfo.cs
- ForceCopyBuildProvider.cs
- IntSecurity.cs
- HwndAppCommandInputProvider.cs
- InOutArgument.cs
- EntitySetDataBindingList.cs
- GridSplitterAutomationPeer.cs
- DataGridLength.cs
- TemplateColumn.cs
- ContentDesigner.cs
- TargetException.cs
- XhtmlBasicPageAdapter.cs
- IsolatedStorageFileStream.cs
- AffineTransform3D.cs
- Image.cs
- DockEditor.cs
- RichTextBox.cs
- HierarchicalDataBoundControl.cs
- StatusBarPanel.cs
- PropagatorResult.cs
- MergeFailedEvent.cs
- DataAccessException.cs
- HtmlWindow.cs
- _NetRes.cs
- SqlDataSourceConfigureSelectPanel.cs
- MarkedHighlightComponent.cs
- _UncName.cs
- Walker.cs
- ViewValidator.cs
- WinFormsComponentEditor.cs
- QueryOutputWriter.cs
- SqlCrossApplyToCrossJoin.cs
- XamlToRtfParser.cs
- InfoCardProofToken.cs
- CatalogPart.cs
- AttributeTable.cs
- ListBindingConverter.cs
- DesignColumn.cs
- ArgumentException.cs
- DropSource.cs
- ExtensionQuery.cs
- UInt16Converter.cs
- PrintingPermission.cs
- AudioLevelUpdatedEventArgs.cs
- COM2IManagedPerPropertyBrowsingHandler.cs
- MappableObjectManager.cs
- SR.cs
- FSWPathEditor.cs
- SafeNativeMethods.cs
- DataGridPagingPage.cs
- RunClient.cs
- AssemblyHash.cs
- UnsafeNativeMethods.cs
- GeneralTransform.cs
- ProcessInputEventArgs.cs
- CachedFontFamily.cs
- BamlLocalizableResource.cs