Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>While I didn't hide it, I did find another way to get what I wanted. When the color is selected I call a javascript function that gets the color code from the textbox and stores it in a hidden field, then clears the textbox's text, then finally sets the background color of the textbox to the color that was selected.</p> <p>Here is the aspx code:</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="color.aspx.cs" Inherits="color" %&gt; &lt;%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function ColorSelectionChanged() { var txtColorPickerSelector = '#' + txtColorPickerID; var ColorCodeSelector = '#' + ColorCodeID; var colorCode = '#' + $(txtColorPickerSelector).val(); $(txtColorPickerSelector).val('').css('background-color', colorCode); $(ColorCodeSelector).val(colorCode); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;asp:HiddenField ID="ColorCode" runat="server" /&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server" /&gt; &lt;asp:TextBox ID="txtColorPicker" runat="server" Width="2em"&gt;&lt;/asp:TextBox&gt; &lt;cc1:ColorPickerExtender ID="txtColor_ColorPickerExtender" runat="server" TargetControlID="txtColorPicker" OnClientColorSelectionChanged="ColorSelectionChanged" /&gt; &amp;nbsp;&lt;asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit" /&gt; &lt;asp:Label ID="lblColorCode" runat="server"&gt;&lt;/asp:Label&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; &lt;script type="text/javascript"&gt; var txtColorPickerID = '&lt;%=txtColorPicker.ClientID %&gt;'; var ColorCodeID = '&lt;%=ColorCode.ClientID %&gt;'; &lt;/script&gt; </code></pre> <p>And the code behind:</p> <pre><code>using System; using System.Drawing; public partial class color : System.Web.UI.Page { protected void btnSubmit_Click(object sender, EventArgs e) { lblColorCode.Text = ColorCode.Value; txtColorPicker.BackColor = ColorTranslator.FromHtml(ColorCode.Value); } } </code></pre> <p>I just assign the code to the label to prove that color code is being submitted. Sorry for the aspx formatting. Tested and working in Chrome, IE 6, IE 7, Firefox 3, Opera 9, and Safari 4.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload