Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / xsp / System / Web / Extensions / ui / ExtenderControl.cs / 2 / ExtenderControl.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Security.Permissions; using System.Web; using System.Web.UI; using System.Web.Resources; using System.Web.Util; [ AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal), DefaultProperty("TargetControlID"), Designer("System.Web.UI.Design.ExtenderControlDesigner, " + AssemblyRef.SystemWebExtensionsDesign), NonVisualControl(), ParseChildren(true), PersistChildren(false), ToolboxItem("System.Web.UI.Design.ExtenderControlToolboxItem, " + AssemblyRef.SystemWebExtensionsDesign), ] public abstract class ExtenderControl : Control, IExtenderControl { private string _targetControlID; private IScriptManagerInternal _scriptManager; private new IPage _page; protected ExtenderControl() { } internal ExtenderControl(IScriptManagerInternal scriptManager, IPage page) { _scriptManager = scriptManager; _page = page; } private IPage IPage { get { if (_page != null) { return _page; } else { Page page = Page; if (page == null) { throw new InvalidOperationException(AtlasWeb.Common_PageCannotBeNull); } return new PageWrapper(page); } } } private IScriptManagerInternal ScriptManager { get { if (_scriptManager == null) { Page page = Page; if (page == null) { throw new InvalidOperationException(AtlasWeb.Common_PageCannotBeNull); } _scriptManager = System.Web.UI.ScriptManager.GetCurrent(page); if (_scriptManager == null) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.Common_ScriptManagerRequired, ID)); } } return _scriptManager; } } [ Category("Behavior"), DefaultValue(""), IDReferenceProperty, ResourceDescription("ExtenderControl_TargetControlID"), SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ID"), ] public string TargetControlID { get { return (_targetControlID == null) ? String.Empty : _targetControlID; } set { _targetControlID = value; } } [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never) ] public override bool Visible { get { return base.Visible; } set { throw new NotImplementedException(); } } ////// Finds the closest UpdatePanel in the parent controls of the specified control. /// /// The control for which we want the closest UpdatePanel. ///An UpdatePanel or null if none was found. private static UpdatePanel FindUpdatePanel(Control control) { Control parent = control.Parent; while (parent != null) { UpdatePanel parentPanel = parent as UpdatePanel; if (parentPanel != null) { return parentPanel; } parent = parent.Parent; } return null; } [SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers")] protected internal override void OnPreRender(EventArgs e) { base.OnPreRender(e); RegisterWithScriptManager(); } private void RegisterWithScriptManager() { if (String.IsNullOrEmpty(TargetControlID)) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.ExtenderControl_TargetControlIDEmpty, ID)); } Control targetControl = FindControl(TargetControlID); if (targetControl == null) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.ExtenderControl_TargetControlIDInvalid, ID, TargetControlID)); } // Check if the target control and its extender are in the same UpdatePanel if any: if (FindUpdatePanel(this) != FindUpdatePanel(targetControl)) { throw new InvalidOperationException(AtlasWeb.ExtenderControl_TargetControlDifferentUpdatePanel); } ScriptManager.RegisterExtenderControl(this, targetControl); } protected internal override void Render(HtmlTextWriter writer) { base.Render(writer); // DevDiv 97460: ScriptDescriptors only render if in server form, verify to avoid silently failing. IPage.VerifyRenderingInServerForm(this); // ScriptManager cannot be found in DesignMode, so do not attempt to register scripts. if (!DesignMode) { ScriptManager.RegisterScriptDescriptors(this); } } protected abstract IEnumerableGetScriptDescriptors(Control targetControl); [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Implementation will likely return a new collection, which is too slow for a property")] protected abstract IEnumerable GetScriptReferences(); #region IExtenderControl Members IEnumerable IExtenderControl.GetScriptDescriptors(Control targetControl) { return GetScriptDescriptors(targetControl); } IEnumerable IExtenderControl.GetScriptReferences() { return GetScriptReferences(); } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Security.Permissions; using System.Web; using System.Web.UI; using System.Web.Resources; using System.Web.Util; [ AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal), DefaultProperty("TargetControlID"), Designer("System.Web.UI.Design.ExtenderControlDesigner, " + AssemblyRef.SystemWebExtensionsDesign), NonVisualControl(), ParseChildren(true), PersistChildren(false), ToolboxItem("System.Web.UI.Design.ExtenderControlToolboxItem, " + AssemblyRef.SystemWebExtensionsDesign), ] public abstract class ExtenderControl : Control, IExtenderControl { private string _targetControlID; private IScriptManagerInternal _scriptManager; private new IPage _page; protected ExtenderControl() { } internal ExtenderControl(IScriptManagerInternal scriptManager, IPage page) { _scriptManager = scriptManager; _page = page; } private IPage IPage { get { if (_page != null) { return _page; } else { Page page = Page; if (page == null) { throw new InvalidOperationException(AtlasWeb.Common_PageCannotBeNull); } return new PageWrapper(page); } } } private IScriptManagerInternal ScriptManager { get { if (_scriptManager == null) { Page page = Page; if (page == null) { throw new InvalidOperationException(AtlasWeb.Common_PageCannotBeNull); } _scriptManager = System.Web.UI.ScriptManager.GetCurrent(page); if (_scriptManager == null) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.Common_ScriptManagerRequired, ID)); } } return _scriptManager; } } [ Category("Behavior"), DefaultValue(""), IDReferenceProperty, ResourceDescription("ExtenderControl_TargetControlID"), SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ID"), ] public string TargetControlID { get { return (_targetControlID == null) ? String.Empty : _targetControlID; } set { _targetControlID = value; } } [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never) ] public override bool Visible { get { return base.Visible; } set { throw new NotImplementedException(); } } ////// Finds the closest UpdatePanel in the parent controls of the specified control. /// /// The control for which we want the closest UpdatePanel. ///An UpdatePanel or null if none was found. private static UpdatePanel FindUpdatePanel(Control control) { Control parent = control.Parent; while (parent != null) { UpdatePanel parentPanel = parent as UpdatePanel; if (parentPanel != null) { return parentPanel; } parent = parent.Parent; } return null; } [SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers")] protected internal override void OnPreRender(EventArgs e) { base.OnPreRender(e); RegisterWithScriptManager(); } private void RegisterWithScriptManager() { if (String.IsNullOrEmpty(TargetControlID)) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.ExtenderControl_TargetControlIDEmpty, ID)); } Control targetControl = FindControl(TargetControlID); if (targetControl == null) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.ExtenderControl_TargetControlIDInvalid, ID, TargetControlID)); } // Check if the target control and its extender are in the same UpdatePanel if any: if (FindUpdatePanel(this) != FindUpdatePanel(targetControl)) { throw new InvalidOperationException(AtlasWeb.ExtenderControl_TargetControlDifferentUpdatePanel); } ScriptManager.RegisterExtenderControl(this, targetControl); } protected internal override void Render(HtmlTextWriter writer) { base.Render(writer); // DevDiv 97460: ScriptDescriptors only render if in server form, verify to avoid silently failing. IPage.VerifyRenderingInServerForm(this); // ScriptManager cannot be found in DesignMode, so do not attempt to register scripts. if (!DesignMode) { ScriptManager.RegisterScriptDescriptors(this); } } protected abstract IEnumerableGetScriptDescriptors(Control targetControl); [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Implementation will likely return a new collection, which is too slow for a property")] protected abstract IEnumerable GetScriptReferences(); #region IExtenderControl Members IEnumerable IExtenderControl.GetScriptDescriptors(Control targetControl) { return GetScriptDescriptors(targetControl); } IEnumerable IExtenderControl.GetScriptReferences() { return GetScriptReferences(); } #endregion } } // 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
- SmiConnection.cs
- OrthographicCamera.cs
- WebMessageEncoderFactory.cs
- ErrorWebPart.cs
- AttributeQuery.cs
- RoutedUICommand.cs
- SecurityTokenProvider.cs
- ObjectSet.cs
- OleDragDropHandler.cs
- InvalidProgramException.cs
- DataComponentGenerator.cs
- DbConnectionStringBuilder.cs
- EventMap.cs
- _NativeSSPI.cs
- DocumentAutomationPeer.cs
- ZoneIdentityPermission.cs
- PluralizationService.cs
- MetadataItemCollectionFactory.cs
- DataSourceGeneratorException.cs
- RowBinding.cs
- BinHexDecoder.cs
- Random.cs
- PtsCache.cs
- validation.cs
- TemplateInstanceAttribute.cs
- MessageQueueInstaller.cs
- HwndProxyElementProvider.cs
- ProbeMatchesCD1.cs
- XPathMultyIterator.cs
- MapPathBasedVirtualPathProvider.cs
- EntityEntry.cs
- LongTypeConverter.cs
- MethodExpression.cs
- IResourceProvider.cs
- OletxCommittableTransaction.cs
- FixedHighlight.cs
- ViewKeyConstraint.cs
- QilInvokeEarlyBound.cs
- SecurityManager.cs
- ExtensionSimplifierMarkupObject.cs
- Translator.cs
- MetadataSource.cs
- ResolveNameEventArgs.cs
- QuaternionAnimationBase.cs
- ConfigurationLockCollection.cs
- ValueTable.cs
- COM2TypeInfoProcessor.cs
- PropertyChangingEventArgs.cs
- OneOfScalarConst.cs
- HttpAsyncResult.cs
- SemanticResolver.cs
- PageAdapter.cs
- TemplatedMailWebEventProvider.cs
- MergablePropertyAttribute.cs
- ReferentialConstraint.cs
- MailAddressCollection.cs
- PopupRootAutomationPeer.cs
- DebugHandleTracker.cs
- ClassData.cs
- ProcessModelInfo.cs
- QuadTree.cs
- RemoteCryptoTokenProvider.cs
- BamlResourceContent.cs
- SqlClientFactory.cs
- CompositeFontInfo.cs
- EnumConverter.cs
- FileIOPermission.cs
- LinqToSqlWrapper.cs
- FormatException.cs
- PerformanceCounterPermissionEntry.cs
- MulticastIPAddressInformationCollection.cs
- RtfToXamlLexer.cs
- CircleHotSpot.cs
- SqlUserDefinedAggregateAttribute.cs
- ExtenderProvidedPropertyAttribute.cs
- WorkflowEventArgs.cs
- WriteableBitmap.cs
- DebugView.cs
- HiddenFieldDesigner.cs
- ThousandthOfEmRealPoints.cs
- PieceNameHelper.cs
- GeneralTransform2DTo3D.cs
- DataList.cs
- LoginName.cs
- BrowserTree.cs
- TransactionScope.cs
- TextSelection.cs
- XmlSchemaRedefine.cs
- SafeLocalMemHandle.cs
- DBCommand.cs
- CommonDialog.cs
- DateTimeFormat.cs
- Overlapped.cs
- Converter.cs
- SchemaInfo.cs
- ExpressionDumper.cs
- WinEventQueueItem.cs
- IDReferencePropertyAttribute.cs
- MaxSessionCountExceededException.cs
- Dictionary.cs