I asked a question about this already, but I wrong-phrased it.
I have a method GetRandColor() on the server that returns a System.Drawing.Color object.
What I want is to be able to set html attributes using this when the page loads. So as an example,
<html>
<body bgcolor="#GetRandColor()">
<h1>Hello world!</h1>
</body>
</html>
You can’t return a
System.Drawing.Colorobject from your function because browsers only understand text. So instead, you should return the string representation of the color, be in RGB, HEX format or what have you.Your method then should look like this:
And you can set the background of your form as so: