This is how it works: when the user clicks the TextBox, a palette of colors comes up, and then the user selects the color on a client-side with the JavaScript Function. So, what I need is that value of that color selected. Either get the JS as a text into the (asp:TextBox) to reference the value in C# or get the TextBox value selected directly into C#, if that makes sense.
This is my JavaScript Code:
<script type="text/javascript">
$(function () {
$('#COLOR_ALPHA_TEXTBOX1').colorPicker({ pickerDefault: "E1E1E1", colors: ["E1E1E1", "33CC00", "FFF000", "CC0000", "996600", "FF9900", "303030", "0066FF", "F9A7B0", "9A0EEA"], transparency: true });
$('#COLOR_ALPHA_TEXTBOX2').colorPicker({ pickerDefault: "E1E1E1", colors: ["E1E1E1", "33CC00", "FFF000", "CC0000", "996600", "FF9900", "303030", "0066FF", "F9A7B0", "9A0EEA"], transparency: true });
});
</script>
This is my aspx Code:
<asp:Table ID="Table" runat="server" style="border: medium solid #000000">
<asp:TableRow>
<asp:TableCell ID="TC2BC" HorizontalAlign="left" VerticalAlign="top">
<asp:TextBox ID="COLOR_ALPHA_TEXTBOX1" type="text" runat="server" Visible="False"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="TC9BC" HorizontalAlign="left" VerticalAlign="top" >
<asp:TextBox ID="COLOR_ALPHA_TEXTBOX2" type="text" runat="server" Visible="False"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
This is my C# Code:
private void SaveNumberOfColors()
{
SqlCommand cmd = null;
string conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string queryString = @"INSERT INTO NUMBER_COLORS " +
"VALUES(" +
"@SiteID, @AlphaFirst )";
using (SqlConnection connection =
new SqlConnection(conn))
{
SqlCommand command =
new SqlCommand(queryString, connection);
connection.Open();
cmd = new SqlCommand(queryString);
cmd.Connection = connection;
cmd.Parameters.Add(new SqlParameter("@SiteID",
System.Data.SqlDbType.NVarChar,
20,
"Site_ID"));
cmd.Parameters["@SiteID"].Value = foo.Site_ID;
cmd.Parameters.Add(new SqlParameter("@AlphaFirst",
System.Data.SqlDbType.NVarChar,
20,
"AlphaFirst"));
cmd.Parameters["@AlphaFirst"].Value = ?????;
cmd.ExecuteReader();
}
}