Export (0) Print
Expand All

ConnectionStringEditor Class

Note: This class is new in the .NET Framework version 2.0.

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)

public class ConnectionStringEditor : UITypeEditor
public class ConnectionStringEditor extends UITypeEditor
public class ConnectionStringEditor extends UITypeEditor

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;
        }

    }
    
}

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

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0
Show:
© 2014 Microsoft