Search code examples
c#asp.netsharepoint-2007colorspalette

Making a menu (color palette) from looping through colors


I have the following code:

        foreach (Color color in new ColorConverter().GetStandardValues()) 
        { 
            output.Write(color.ToString()); 
        }

What would be the syntax to get it to show as a color palette instead of just listing the colors?


Solution

  • I think you're looking for something like this:

    StringBuiler sb = new StringBuiler();
    foreach (Color color in new ColorConverter().GetStandardValues())          
    {             
      sb.Append(string.format("<div style=\"float:left;width:5px;height:5px;background-color:#{0}\"></div>". color.ColorCode));        
    } 
    
    ltrlColorPalette.Text = sb.ToString();