Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / ControlIdConverter.cs / 1305376 / ControlIdConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Globalization; using System.Reflection; using System.Web.Util; using System.Security.Permissions; ////// TypeConverter for ControlParameter's ControlID property. /// public class ControlIDConverter : StringConverter { ////// protected virtual bool FilterControl(Control control) { return true; } ///Determines whether a given control should have its id added to the StandardValuesCollection. ////// Returns a list of all control IDs in the container. /// private string[] GetControls(IDesignerHost host, object instance) { IContainer container = host.Container; // Locate nearest container IComponent component = instance as IComponent; if (component != null && component.Site != null) { container = component.Site.Container; } if (container == null) { return null; } ComponentCollection allComponents = container.Components; ArrayList array = new ArrayList(); // For each control in the container foreach (IComponent comp in (IEnumerable)allComponents) { Control control = comp as Control; // Ignore DesignerHost.RootComponent (Page or UserControl), controls that don't have ID's, // and the Control itself if (control != null && control != instance && control != host.RootComponent && control.ID != null && control.ID.Length > 0 && FilterControl(control)) { array.Add(control.ID); } } array.Sort(Comparer.Default); return (string[])array.ToArray(typeof(string)); } ////// Returns a collection of standard values retrieved from the context specified /// by the specified type descriptor. /// public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (context == null) { return null; } IDesignerHost host = (IDesignerHost)context.GetService(typeof(IDesignerHost)); Debug.Assert(host != null, "Unable to get IDesignerHost in ControlIDConverter"); if (host != null) { string[] controlIDs = GetControls(host, context.Instance); if (controlIDs == null) { return null; } return new StandardValuesCollection(controlIDs); } return null; } ////// Gets whether or not the context specified contains exclusive standard values. /// public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return false; } ////// Gets whether or not the specified context contains supported standard values. /// public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return (context != null); } } } // 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
- MetadataElement.cs
- TypeToken.cs
- SelectionEditor.cs
- QueryOutputWriter.cs
- PagesSection.cs
- BulletChrome.cs
- PnrpPermission.cs
- GraphicsPath.cs
- BookmarkOptionsHelper.cs
- XmlILAnnotation.cs
- DeferrableContent.cs
- StateMachineSubscriptionManager.cs
- XamlSerializerUtil.cs
- ClientRoleProvider.cs
- CounterSample.cs
- OleAutBinder.cs
- FlowDocumentScrollViewer.cs
- _BasicClient.cs
- CellIdBoolean.cs
- SafeEventLogWriteHandle.cs
- RNGCryptoServiceProvider.cs
- TextReader.cs
- TextBreakpoint.cs
- AttributedMetaModel.cs
- SqlDataSourceCustomCommandEditor.cs
- SqlProviderServices.cs
- SessionIDManager.cs
- SecurityContext.cs
- BindingValueChangedEventArgs.cs
- NamespaceTable.cs
- ColorConvertedBitmap.cs
- IERequestCache.cs
- JavascriptCallbackResponseProperty.cs
- Collection.cs
- StorageConditionPropertyMapping.cs
- BitmapEffectInputConnector.cs
- Attributes.cs
- Size3D.cs
- BufferModeSettings.cs
- ProviderSettings.cs
- ImageCodecInfoPrivate.cs
- SystemNetworkInterface.cs
- BeginStoryboard.cs
- SoapIncludeAttribute.cs
- XmlTextWriter.cs
- SqlNotificationRequest.cs
- Script.cs
- TreeViewTemplateSelector.cs
- smtpconnection.cs
- WindowsRegion.cs
- SynchronousChannelMergeEnumerator.cs
- RemoteWebConfigurationHost.cs
- ScriptingWebServicesSectionGroup.cs
- PartialArray.cs
- ArgumentNullException.cs
- MemoryRecordBuffer.cs
- Formatter.cs
- SchemaNames.cs
- Vector.cs
- NativeMethods.cs
- ObjectStateManager.cs
- Lazy.cs
- IsolatedStorageException.cs
- Events.cs
- ContainerFilterService.cs
- RenderDataDrawingContext.cs
- RequestSecurityToken.cs
- WhiteSpaceTrimStringConverter.cs
- ThreadSafeList.cs
- SafeFileMappingHandle.cs
- IIS7WorkerRequest.cs
- RpcResponse.cs
- DuplicateWaitObjectException.cs
- DetailsViewPageEventArgs.cs
- GeometryGroup.cs
- JsonEncodingStreamWrapper.cs
- IDataContractSurrogate.cs
- StructuralCache.cs
- ProfessionalColors.cs
- UIAgentRequest.cs
- FreeFormDesigner.cs
- HandlerBase.cs
- AssociationTypeEmitter.cs
- ChannelServices.cs
- OdbcErrorCollection.cs
- BindingExpression.cs
- MapPathBasedVirtualPathProvider.cs
- XmlNotation.cs
- BaseUriHelper.cs
- TCPClient.cs
- IListConverters.cs
- ToolStripPanelCell.cs
- SqlCommandSet.cs
- ping.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- StringUtil.cs
- CapabilitiesSection.cs
- NullReferenceException.cs
- CopyAction.cs
- TextDecoration.cs