erewien
erewien

Reputation: 369

Working with colors in ASP.NET using C#

I am currently trying out some things in asp.net and ran into following issue: I have currently 2 color pickers, button and label like:

 <input type="color" runat="server" id="colorPick1" name="colorPick"/>
 <input type="color" runat="server" id="colorPick1" name="colorPick"/>
 <asp:Button ID="Button1" runat="server" Text="Mix Colors" OnClick="Button1_Click" />
 <asp:Label ID="resultMix" runat="server" ForeColor="White" style="text-align: center" BackColor="White"></asp:Label>

the idea is that I take the 2 colors, munch them into algorithm and write something into label with text color that is returned via the algorithm. Basically it would be something like:

private Color algorithm(Color c1, Color c2){ 
Color c;
//do something
return c;
}

My visual studio couldn't even find the "using System.Windows.Media;" so that the Color class of C# would be visible. Is there some elegant solution to this?

I use the C# in my page, not VB

Upvotes: 2

Views: 1711

Answers (1)

codeandcloud
codeandcloud

Reputation: 55248

Use System.Drawing.Color.

There are methods like

  1. Color.FromName(strng name);
  2. Color.FromArgb(int red, int green, int blue);
  3. Color.FromKnowColor(Color color);

Upvotes: 3

Related Questions