title: Setting color by random number asp.net
body: <p>I have a method to get a random color:</p>
  
  <pre><code> private System.Drawing.Color GetRandColor()
      {
          Random r = new Random(DateTime.Now.Millisecond);
  
          System.Drawing.Color[] colours = 
          {
              System.Drawing.Color.Yellow, 
              System.Drawing.Color.LightGreen, 
              System.Drawing.Color.LightCyan,
              System.Drawing.Color.LightSalmon,  
              System.Drawing.Color.LightSkyBlue
          };
  
          int i = r.Next(0, colours.Length - 1);
  
          System.Drawing.Color c = colours[i];
  
          return c; 
      }
  </code></pre>
  
  <p>So what I want to do, is to have this random color passed into my html when the page loads. 
  So it will be put in Page_Load somehow: </p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
      {
                // code to set button color 
      } 
  
  &lt;asp:Button ID="Button1" runat="server" Text="Button" BackColor=GetRandColor()/&gt;
  </code></pre>