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
- PictureBox.cs
- WorkflowRuntimeBehavior.cs
- LazyInitializer.cs
- ListItem.cs
- XamlTreeBuilderBamlRecordWriter.cs
- EventWaitHandleSecurity.cs
- XamlWriter.cs
- TreeWalker.cs
- XamlInterfaces.cs
- BaseDataBoundControl.cs
- ExecutionEngineException.cs
- MetabaseSettings.cs
- KnownBoxes.cs
- EtwTrace.cs
- TextEmbeddedObject.cs
- TextTreeExtractElementUndoUnit.cs
- LogWriteRestartAreaAsyncResult.cs
- ManagedIStream.cs
- DataTableReader.cs
- IOException.cs
- bidPrivateBase.cs
- ChooseAction.cs
- ToolStripContentPanel.cs
- COMException.cs
- GradientStopCollection.cs
- UpdateCompiler.cs
- XmlSchemaSet.cs
- StorageRoot.cs
- validationstate.cs
- BackStopAuthenticationModule.cs
- ImplicitInputBrush.cs
- ZeroOpNode.cs
- ellipse.cs
- VisualBasicHelper.cs
- DataTableClearEvent.cs
- panel.cs
- CollectionViewSource.cs
- EffectiveValueEntry.cs
- COM2ComponentEditor.cs
- HtmlValidatorAdapter.cs
- StringFunctions.cs
- BrushMappingModeValidation.cs
- SystemException.cs
- QueryConverter.cs
- Int64Animation.cs
- InputReport.cs
- DocumentViewerAutomationPeer.cs
- HtmlControlPersistable.cs
- CustomBinding.cs
- ApplyImportsAction.cs
- OneOfConst.cs
- Lasso.cs
- SafePointer.cs
- DiffuseMaterial.cs
- IImplicitResourceProvider.cs
- ADMembershipUser.cs
- Statements.cs
- GetLedgerEntryForRecipientRequest.cs
- OleDbWrapper.cs
- ControlBuilderAttribute.cs
- Point4DValueSerializer.cs
- XmlILTrace.cs
- CallbackValidatorAttribute.cs
- dsa.cs
- OLEDB_Enum.cs
- EncodingNLS.cs
- FixedSOMTableCell.cs
- OdbcDataAdapter.cs
- FixedSOMLineCollection.cs
- AppliedDeviceFiltersDialog.cs
- RecipientInfo.cs
- Math.cs
- MetadataArtifactLoaderComposite.cs
- _SafeNetHandles.cs
- HtmlTableCell.cs
- RankException.cs
- BufferModeSettings.cs
- Nullable.cs
- DesignerVerbCollection.cs
- GetIsBrowserClientRequest.cs
- ValueTypeIndexerReference.cs
- NetworkInterface.cs
- PropertyConverter.cs
- MatrixTransform.cs
- GeometryGroup.cs
- BinaryCommonClasses.cs
- ProtocolsConfigurationEntry.cs
- OleDbSchemaGuid.cs
- BindingMemberInfo.cs
- Internal.cs
- OracleCommandSet.cs
- PackageFilter.cs
- ConnectionStringsSection.cs
- AssertFilter.cs
- CatalogZone.cs
- WebPartDisplayMode.cs
- Type.cs
- SelectionEditingBehavior.cs
- bindurihelper.cs
- TreeViewCancelEvent.cs