fokz8 fokz8 - 1 year ago 103
ASP.NET (C#) Question

How to select and get color in

As there is no integrated attribute for color in (atleast i haven't found it), i wonder, how do you guys select color?

Let's say i want to create a drawing using bitmap and i want to get background color from the user who selects it using the application.

I've done some code behind, but thing doesn't work, as i manually type in colors like #000 or #fff (using textbox)


<span>Background color</span>
<asp:TextBox ID="inp_bgColor" Width="125px" runat="server"></asp:TextBox>
</label><span style="color:red"><asp:Literal ID="error_bg" runat="server"></asp:Literal></span><br /><br />

and app.aspx.cs

Color txtClr = Color.FromName(inp_bgColor.Text);

I've noticed that System.Drawing.Color is type of ARGB color, so how do i do this?


Answer Source

You can use hex colors like this:

string hex = "#FF3FF3";
Color _color = System.Drawing.ColorTranslator.FromHtml(hex);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download