ColorPicker control


In this topic


About the ColorPicker control

The ColorPicker control provides a runtime dialog box that can be used to select a color. Available colors include all the named colors in the .NET System.Drawing.Color structure. Often, a ColorPicker control is packaged in a composite control, such as a task.

Using the control

  1. The ColorPicker control does not require any other Web Application Developer Framework (ADF) controls on the page (just add the ColorPicker control on the page). Design-time representation of the control does not provide an interactive list of colors. See the following screen shot that shows the ColorPicker control at design-time:


  2. On the ColorPicker Properties page, set the ChosenColor property to define a default display color at runtime. This property can also be used to get the current color at runtime.
  3. Set the ShowColorNames property to false. This will show a grid of colors at runtime. If set to true, a drop-down list of each color and its name will be provided.
  4. To capture the selected color on the client using JavaScript, set the OnColorPickedClient property to a JavaScript function name, for example, colorChosen.  
  5. On the .aspx page, add a JavaScript function of the same name and include two parameters in the function call. See the following code example:
     
[JavaScript]
function colorChosen(sender, color){
    alert(color);
}
  1. To capture the selected color on the server, handle the ColorPicked event. The selected color will be passed to the event method as an argument.
  2. At runtime, click the active color box displayed by the ColorPicker. A drop-down list containing colors appear. 
  3. Click a color to select it. The JavaScript function defined in Step 5 will be called and the name of the selected color will appear in an alert message box. The active color box shows the selected color. See the following screen shot that shows the ColorPicker at runtime:


Members

The following table shows a list of properties related to the ColorPicker control. For more reference information, see the ColorPicker control in the library reference section.
Property name
Type
Description
ChosenColor
color
Gets or sets the current chosen color.
ShowColorNames
Boolean
True shows a drop-down list with one color and name on each line. False shows a grid of colors.
DropDownHeight
string
Height in pixels of the drop-down list.
DisplayText
string
Text shown at runtime next to the color box.
OnColorPickedClient
string
Name of a JavaScript function that is called when a color is selected. Two parameters are passed to the function, sender and color name.

Events

The following table shows an event related to the ColorPicker control:
Event type
Description
ColorPicked
Occurs when a color is selected.


See Also:

Web ADF controls
Customizing the Web Mapping application




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
  • ESRI.ArcGIS.ADF.UI.WebControls.dll