Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / 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 // [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); // 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. //------------------------------------------------------------------------------ ///// // 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 // [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); // 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.///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ViewStateModeByIdAttribute.cs
- Cursor.cs
- GeneratedView.cs
- ECDiffieHellmanPublicKey.cs
- ParameterElementCollection.cs
- EventItfInfo.cs
- oledbconnectionstring.cs
- SurrogateDataContract.cs
- DbProviderFactory.cs
- TimerElapsedEvenArgs.cs
- BrowserDefinitionCollection.cs
- ProviderMetadataCachedInformation.cs
- TextLineBreak.cs
- TableCell.cs
- PropertySegmentSerializer.cs
- EntityContainerEmitter.cs
- LineVisual.cs
- DomainUpDown.cs
- DateTimeConverter.cs
- URLMembershipCondition.cs
- MaskedTextProvider.cs
- BatchParser.cs
- XmlDataProvider.cs
- Aggregates.cs
- MemberExpression.cs
- OutputCacheSettingsSection.cs
- followingsibling.cs
- BaseCollection.cs
- PolicyLevel.cs
- SiteMap.cs
- EventLogPermissionAttribute.cs
- EditorPartCollection.cs
- FillRuleValidation.cs
- ConstraintConverter.cs
- WebPartChrome.cs
- ProxyManager.cs
- MLangCodePageEncoding.cs
- ViewManager.cs
- OleDbSchemaGuid.cs
- DragCompletedEventArgs.cs
- ParagraphVisual.cs
- AuthenticationService.cs
- VectorAnimation.cs
- DescendantBaseQuery.cs
- ValueUnavailableException.cs
- ButtonField.cs
- SequentialOutput.cs
- PropertyGeneratedEventArgs.cs
- elementinformation.cs
- FormsAuthentication.cs
- IpcPort.cs
- CryptoConfig.cs
- PathTooLongException.cs
- QilNode.cs
- PerfService.cs
- Sentence.cs
- RepeaterCommandEventArgs.cs
- SystemIcons.cs
- TextBox.cs
- SQLInt32.cs
- RegexTree.cs
- XmlMemberMapping.cs
- ExpandSegment.cs
- CodeAssignStatement.cs
- NamespaceInfo.cs
- ExpandoClass.cs
- ScrollProviderWrapper.cs
- SqlSupersetValidator.cs
- WindowsGraphics2.cs
- TryCatchDesigner.xaml.cs
- ToolTipAutomationPeer.cs
- WebScriptServiceHost.cs
- AutomationProperties.cs
- AnnouncementEndpointElement.cs
- ColorPalette.cs
- SafeSecurityHelper.cs
- TargetConverter.cs
- TransformedBitmap.cs
- DockPattern.cs
- ReflectionServiceProvider.cs
- ToolStripItemImageRenderEventArgs.cs
- InstanceLockLostException.cs
- ListViewCancelEventArgs.cs
- HeaderCollection.cs
- DbConnectionPoolCounters.cs
- QilIterator.cs
- ComponentResourceKey.cs
- CodeRemoveEventStatement.cs
- HMACSHA1.cs
- ExpressionLink.cs
- SHA512Managed.cs
- CatalogPart.cs
- FacetDescriptionElement.cs
- NumberFormatInfo.cs
- TraceInternal.cs
- TemplateBamlRecordReader.cs
- LocalizeDesigner.cs
- WebEvents.cs
- Mouse.cs
- _LoggingObject.cs