Export (0) Print
Expand All

ConnectionStringEditor Class

Provides a base class for a user interface to select and edit a connection string property at design time.

Namespace:  System.Web.UI.Design
Assembly:  System.Design (in System.Design.dll)

[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public class ConnectionStringEditor : UITypeEditor

The ConnectionStringEditor type exposes the following members.

  NameDescription
Public methodConnectionStringEditorInitializes a new instance of the ConnectionStringEditor class.
Top

  NameDescription
Public propertyIsDropDownResizableGets a value indicating whether drop-down editors should be resizable by the user. (Inherited from UITypeEditor.)
Top

  NameDescription
Public methodEditValue(IServiceProvider, Object)Edits the value of the specified object using the editor style indicated by the GetEditStyle method. (Inherited from UITypeEditor.)
Public methodEditValue(ITypeDescriptorContext, IServiceProvider, Object)Edits the value of the specified object by using the specified service provider and context. (Overrides UITypeEditor.EditValue(ITypeDescriptorContext, IServiceProvider, Object).)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEditStyle()Gets the editor style used by the EditValue method. (Inherited from UITypeEditor.)
Public methodGetEditStyle(ITypeDescriptorContext)Returns the editing style that is associated with the connection string editor for the specified context. (Overrides UITypeEditor.GetEditStyle(ITypeDescriptorContext).)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetPaintValueSupported()Indicates whether this editor supports painting a representation of an object's value. (Inherited from UITypeEditor.)
Public methodGetPaintValueSupported(ITypeDescriptorContext)Indicates whether the specified context supports painting a representation of an object's value within the specified context. (Inherited from UITypeEditor.)
Protected methodGetProviderNameReturns the provider name for the provided instance of the ConnectionStringEditor class.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodPaintValue(PaintValueEventArgs)Paints a representation of the value of an object using the specified PaintValueEventArgs. (Inherited from UITypeEditor.)
Public methodPaintValue(Object, Graphics, Rectangle)Paints a representation of the value of the specified object to the specified canvas. (Inherited from UITypeEditor.)
Protected methodSetProviderNamePuts the provider name on the specified instance of the ConnectionStringEditor class.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

An instance of the ConnectionStringEditor class is a UITypeEditor object that can be used at design time to select and edit a connection string expression and to assign the expression to a control property. For example, the SqlDataSource control uses the ConnectionStringEditor class at design time to set the value of the ConnectionString property.

Use the EditorAttribute attribute to associate the ConnectionStringEditor with a property. When the associated property is edited on the design surface, the designer host calls the EditValue method. The EditValue method displays a user interface for building the connection string expression and returns the connection string that is selected by the user. The GetEditStyle method indicates the display style of the user interface.

The following code example demonstrates how to associate an instance of the ConnectionStringEditor class with a property that is contained within a custom control. When the control property is edited in the design surface, the ConnectionStringEditor class provides the user interface to select and edit a connection string for the property value.

// Define a custom class derived from the SqlDataSource Web control.  
public class SqlDataSourceWithBackup : SqlDataSource
{
    private string _alternateConnectionString;

    // Define an alternate connection string, which could be used 
    // as a fallback value if the primary connection string fails. 

    // The EditorAttribute indicates the property can 
    // be edited at design-time with the ConnectionStringEditor class.
    [
      DefaultValue(""),
      EditorAttribute(typeof(System.Web.UI.Design.ConnectionStringEditor),
                     typeof(System.Drawing.Design.UITypeEditor)),
      Category("Data"),
      Description("The alternate connection string.")
    ]
    public string AlternateConnectionString
    {
        get
        {
            return _alternateConnectionString;
        }
        set
        {
            _alternateConnectionString = value;
        }

    }

}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft