Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

ColorBuilder Class

Provides an HTML color string builder at design time that allows a user to select a color.

Namespace:  System.Web.UI.Design
Assembly:  System.Design (in System.Design.dll)
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public sealed class ColorBuilder

The BuildColor method starts a user interface for selecting a color value.

The ColorBuilder class is not intended for use outside of the design time environment. ColorBuilder requires the IWebFormsBuilderUIService, which is typically available within a Web Forms project at design time. If you want to build HTML color strings, you may want to implement a method that converts the RGB values of a Color object to an HTML-compatible RRGGBB format string. If you intend to use a control to select a color or configure a color, you can build a user interface for this, or you may want to use a PropertyGrid control which allows you to edit Color properties with the default ColorEditor providing a color selection interface.

// Create a parent control.
System.Windows.Forms.Control c = new System.Windows.Forms.Control();            
c.CreateControl();            

// Launch the Color Builder using the specified control  
// parent and an initial HTML format ("RRGGBB") color string.
System.Web.UI.Design.ColorBuilder.BuildColor(this.Component, c, "405599");
// Example designer provides a designer verb menu command to launch the  
// BuildColor method of the ColorBuilder.
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")]
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
public class ColorBuilderDesigner : System.Web.UI.Design.UserControlDesigner
{
    public ColorBuilderDesigner()
    {
    }

    // Provides a designer verb menu command for invoking the BuildColor  
    // method of the ColorBuilder. 
    public override System.ComponentModel.Design.DesignerVerbCollection Verbs
    {
        get
        {
            DesignerVerbCollection dvc = new DesignerVerbCollection();                               
            dvc.Add( new DesignerVerb("Launch Color Builder UI", new EventHandler(this.launchColorBuilder)) ); 
            return dvc;
        }
    }

    // This method handles the "Launch Color Builder UI" menu command.
    // Invokes the BuildColor method of the System.Web.UI.Design.ColorBuilder. 
    private void launchColorBuilder(object sender, EventArgs e)
    {
        // Create a parent control.
        System.Windows.Forms.Control c = new System.Windows.Forms.Control();            
        c.CreateControl();            

        // Launch the Color Builder using the specified control  
        // parent and an initial HTML format ("RRGGBB") color string.
        System.Web.UI.Design.ColorBuilder.BuildColor(this.Component, c, "405599");
    }
}

// Example Web control displays the value of its text property. 
// This control is associated with the ColorBuilderDesigner.
[DesignerAttribute(typeof(ColorBuilderDesigner), typeof(IDesigner))]
public class ColorBuilderControl : System.Web.UI.WebControls.WebControl
{
    private string text;

    [Bindable(true),
    Category("Appearance"),
    DefaultValue("")]
    public string Text
    {
        get
        {
            return text;
        }

        set
        {
            text = value;
        }
    }

    protected override void Render(HtmlTextWriter output)
    {
        output.Write(Text);
    }
}
System.Object
  System.Web.UI.Design.ColorBuilder
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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.