Click to See Complete Forum and Search --> : How to set background color?


binayak
February 14th, 2005, 07:14 PM
Hi,

This is a newbie question. How can I set the background color of the web form page from code behind page model?

I want something like:

private void Page_Load(object sender, System.EventArgs e)
{
//set the background color of the page here
}
I dont want to use any in page scripting for this.

Please Help

jeremiah98383
February 15th, 2005, 01:07 PM
One way to do it would be to add the runat=server id=theBody tags to the body tag in the HTML then in the codebehind have something like protected theBody as HtmlGenericControl

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
theBody.Attributes("bgcolor") = "Red"
End Sub
It is VB code, but you get the idea.