Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- FormViewInsertedEventArgs.cs
- RelatedPropertyManager.cs
- NavigationWindow.cs
- Pair.cs
- ClientConvert.cs
- MediaPlayer.cs
- Cursor.cs
- AuthenticationServiceManager.cs
- SqlMetaData.cs
- ToolStripSeparator.cs
- ReflectEventDescriptor.cs
- NavigationExpr.cs
- RenderData.cs
- DummyDataSource.cs
- AssemblyCache.cs
- ProfileSection.cs
- CalendarSelectionChangedEventArgs.cs
- SpnegoTokenAuthenticator.cs
- MsmqElementBase.cs
- CopyCodeAction.cs
- InstanceDescriptor.cs
- XmlSchemaAttributeGroup.cs
- EntitySqlQueryCacheKey.cs
- DataContractJsonSerializer.cs
- SplitterEvent.cs
- PreviewKeyDownEventArgs.cs
- RectAnimationBase.cs
- StatusBarPanel.cs
- DataGridViewTextBoxEditingControl.cs
- LocatorBase.cs
- IdentityHolder.cs
- LeaseManager.cs
- TreeWalkHelper.cs
- ValueTypeFixupInfo.cs
- TextComposition.cs
- XD.cs
- WindowsToolbarItemAsMenuItem.cs
- LayoutEvent.cs
- MbpInfo.cs
- PropertyPath.cs
- SubMenuStyleCollectionEditor.cs
- ColorPalette.cs
- IncrementalReadDecoders.cs
- MenuItemBindingCollection.cs
- CharEnumerator.cs
- PageCatalogPart.cs
- DoWhileDesigner.xaml.cs
- SqlConnectionFactory.cs
- ToolStripArrowRenderEventArgs.cs
- AutomationPeer.cs
- HostedBindingBehavior.cs
- ParamArrayAttribute.cs
- Nodes.cs
- loginstatus.cs
- XmlSchemaComplexContentExtension.cs
- GifBitmapDecoder.cs
- DecimalConverter.cs
- EnumerableRowCollectionExtensions.cs
- PageClientProxyGenerator.cs
- FileNotFoundException.cs
- OleAutBinder.cs
- GridViewUpdateEventArgs.cs
- StringInfo.cs
- Vector3DAnimationUsingKeyFrames.cs
- CreateBookmarkScope.cs
- SessionStateUtil.cs
- ListViewEditEventArgs.cs
- PngBitmapDecoder.cs
- MetadataPropertyvalue.cs
- GetReadStreamResult.cs
- DataRecordObjectView.cs
- SafeWaitHandle.cs
- SmtpAuthenticationManager.cs
- OrderByBuilder.cs
- SerializationException.cs
- ToolStripItemClickedEventArgs.cs
- figurelengthconverter.cs
- ObjectConverter.cs
- DateTimeSerializationSection.cs
- WindowsToolbarAsMenu.cs
- Material.cs
- BufferedGraphicsContext.cs
- Graph.cs
- AuthenticateEventArgs.cs
- XmlNamespaceManager.cs
- MostlySingletonList.cs
- ScalarConstant.cs
- ELinqQueryState.cs
- Switch.cs
- SystemIPGlobalStatistics.cs
- CatalogPartChrome.cs
- StateMachineExecutionState.cs
- LineSegment.cs
- WebPartConnection.cs
- DetailsViewCommandEventArgs.cs
- _Rfc2616CacheValidators.cs
- DataServiceRequestArgs.cs
- WebBrowserNavigatingEventHandler.cs
- SecurityPolicySection.cs
- NoResizeHandleGlyph.cs