Link to home
Start Free TrialLog in
Avatar of jeremyduj
jeremyduj

asked on

Color generator ASP.NET

Is there a asp.net random color generator function or .dll that I can include in my project that I can refer to create a randomly generated HTML color?

For instance, I'd like to be able to do this (if it existed):

ColorGenerator myColorGenerator = new ColorGenerator();
string color = myColorGenerator.getColor();  //returns a random HTML hex color code

Avatar of chinu1310
chinu1310
Flag of United States of America image

If that doesn't work check this.
http://steveorr.net/articles/ImproveYourImages.aspx

Create 3 random numbers from 2 to 255 (R,G,B)
than create color from these three.

Tested and working

Insert System.Drawing

And this much.

Random random = new Random();
        int R = random.Next(225);
        int G = random.Next(225);
        int B = random.Next(225);

        Color RandomColor = Color.FromArgb(R,G,B);
ASKER CERTIFIED SOLUTION
Avatar of chinu1310
chinu1310
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bob Learned
Easy way to get HTML colors:
   ColorTranslator.ToHtml(Color.Red)

Bob