Create a randomly generated bg color using VB code
06 January 2010 Tips  Marek Sienkiewicz
Bubble
This is just a muse nothing serious and I doubt whether it would be the method that most would choose.
 
Turn the body html tag into a server side control with <body id = “PageBody”>
 
In the code behind add Imports System.Drawing at the top of the page and then the following script under the page load event:
 
        Dim redColor As Integer
        Dim greenColor As Integer
        Dim blueColor As Integer
        Dim surpriseColor As New Random
        redColor = surpriseColor.Next(0, 255)
        greenColor = surpriseColor.Next(0, 255)
        blueColor = surpriseColor.Next(0, 255)
        PageBody.Attributes.Add("bgColor", Color.FromArgb  _
        (redColor, greenColor, blueColor).ToArgb)
 
Now every time the page is refreshed a new background colour is generated.





Please post your comments:

Name

Email
                           

   

Enter the text you see in the box:

Captcha Image