Click here to Skip to main content
15,893,588 members
Articles / Web Development / ASP.NET

An ASP.NET Color Picker Control based on YUI Color picker

Rate me:
Please Sign up or sign in to vote.
4.53/5 (9 votes)
3 Jun 2009Ms-PL7 min read 43.2K   944   19  
An ASP.NET Color Picker Control based on YUI Color picker
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MultiplePickers.aspx.cs" Inherits="ColorPicker.FloatingDialog.MultiplePickers" %>
<%@ Register tagprefix="yui" Namespace="ColorPicker" %>
<%@ Register assembly="ColorPicker" namespace="YUI.Controls" tagprefix="Yui" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Multiple pickers</title>
<!-- Combo-handled YUI CSS files: -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.7.0/build/slider/assets/skins/sam/slider.css&2.7.0/build/colorpicker/assets/skins/sam/colorpicker.css&2.7.0/build/container/assets/skins/sam/container.css&2.7.0/build/logger/assets/skins/sam/logger.css" />
<!-- Combo-handled YUI JS files: -->
<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.7.0/build/yahoo/yahoo-debug.js&2.7.0/build/dom/dom-debug.js&2.7.0/build/event/event-debug.js&2.7.0/build/animation/animation-debug.js&2.7.0/build/dragdrop/dragdrop-debug.js&2.7.0/build/slider/slider-debug.js&2.7.0/build/element/element-debug.js&2.7.0/build/colorpicker/colorpicker-debug.js&2.7.0/build/connection/connection-debug.js&2.7.0/build/container/container-debug.js&2.7.0/build/logger/logger-debug.js"></script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Label runat="server" ID="Message" />
    <div>
    This example shows two color pickers, rendered in inline windows. by default they are both hidden (See the IsHidden property). <br />
    Notice that the LoadYui property is set to false. Instead, YUI is loaded manually as two includes - one for the CSS and one for the JS files.<br />
    Picker 1 is non-modal and also shows the nearest web-safe colors  <br />
    Picker 2 has a modal behavior. <br />
    Both pickers are initially hidden.
    
    <yui:ColorPicker 
      ID="YuiColorPicker1" 
      runat="server" 
      ColorPickerMode="FloatingDialog"
      ModalBehavior="false"   
      ShowWebSafe="true"   
      EnableAnimation="true"
      OnColorChanged="YuiColorPicker_ColorChanged"
      LoadYui="false"
      IsHidden="true"
        />
    
    <yui:ColorPicker 
      ID="YuiColorPicker2" 
      runat="server" 
      ColorPickerMode="FloatingDialog"
      ModalBehavior="true"      
      OnValueChanged="YuiColorPicker_ColorChanged"
      LoadYui="false"
      IsHidden="true"
        />        
        
    </div>
    
    <asp:Button ID="Button1" runat="server" Text="Postback" OnClick="Btn_Click"  />
    
    <input type="button" ID="btnShow" runat="server" value="Show 1" />
    <input type="button" ID="btnHide" runat="server" value="Hide 1" />
    <input type="button" ID="btnShow2" runat="server" value="Show 2" />
    <input type="button" ID="btnHide2" runat="server" value="Hide 2" />
    <input type="button" ID="btnGetValue" runat="server" value="Show Value 1" />
    <input type="button" ID="btnGetValue2" runat="server" value="Show Value 2" />
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Product Manager CodeRun
United States United States
I'm a founder and product manager at CodeRun. I'm interested in C#, Code technology, Javascript, and everything in between.
Aside from these professional interests, I enjoy playing and listening to music, movies, diving, hiking, biking, wine, food, and everything life has to offer.

Comments and Discussions