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
- EntityDataSourceDesigner.cs
- SimpleFieldTemplateUserControl.cs
- FileIOPermission.cs
- ClientEventManager.cs
- AppSecurityManager.cs
- DeferredSelectedIndexReference.cs
- WindowsGraphicsCacheManager.cs
- NullableConverter.cs
- StatusBarPanelClickEvent.cs
- HttpContextServiceHost.cs
- MailMessageEventArgs.cs
- ApplicationInterop.cs
- CodeTypeDeclaration.cs
- Clock.cs
- TCPClient.cs
- ResourcePermissionBaseEntry.cs
- EncryptedKeyIdentifierClause.cs
- ParamArrayAttribute.cs
- QualifierSet.cs
- CellRelation.cs
- isolationinterop.cs
- Hyperlink.cs
- PositiveTimeSpanValidator.cs
- Atom10FormatterFactory.cs
- SharedStatics.cs
- ICollection.cs
- smtpconnection.cs
- RankException.cs
- ListItemConverter.cs
- Hash.cs
- WpfGeneratedKnownTypes.cs
- DefaultMemberAttribute.cs
- FileNotFoundException.cs
- Stack.cs
- CodeTypeOfExpression.cs
- AnnotationHighlightLayer.cs
- Rect3DConverter.cs
- ConstrainedDataObject.cs
- LingerOption.cs
- FileLogRecordEnumerator.cs
- BindingOperations.cs
- RelativeSource.cs
- DocumentOrderComparer.cs
- RuleConditionDialog.Designer.cs
- WebContext.cs
- TableProvider.cs
- ThousandthOfEmRealPoints.cs
- XPathChildIterator.cs
- ListInitExpression.cs
- InvokeMethod.cs
- Rect3D.cs
- SystemIPInterfaceStatistics.cs
- RemotingException.cs
- RealizationContext.cs
- Expander.cs
- MULTI_QI.cs
- ApplicationTrust.cs
- Cloud.cs
- ToolStripItem.cs
- UnicodeEncoding.cs
- odbcmetadatacolumnnames.cs
- Manipulation.cs
- CheckBox.cs
- ComAdminWrapper.cs
- RuntimeResourceSet.cs
- AnonymousIdentificationSection.cs
- DataGridAddNewRow.cs
- FontFamily.cs
- UidManager.cs
- SingleKeyFrameCollection.cs
- SqlConnectionHelper.cs
- NextPreviousPagerField.cs
- LogExtentCollection.cs
- COM2ComponentEditor.cs
- SqlErrorCollection.cs
- ConnectionPool.cs
- PropertyPushdownHelper.cs
- ChannelServices.cs
- TrustManager.cs
- Compiler.cs
- FormViewInsertEventArgs.cs
- XmlQuerySequence.cs
- TextEditorSelection.cs
- GridViewHeaderRowPresenter.cs
- MatrixAnimationUsingKeyFrames.cs
- ActivityMarkupSerializationProvider.cs
- PermissionRequestEvidence.cs
- EventPrivateKey.cs
- FieldBuilder.cs
- HttpListenerResponse.cs
- SoapFaultCodes.cs
- ContentFilePart.cs
- XmlSignatureProperties.cs
- TextServicesContext.cs
- SuspendDesigner.cs
- Permission.cs
- ColumnMap.cs
- DesignOnlyAttribute.cs
- Rect3DConverter.cs
- ScriptingProfileServiceSection.cs