How to set background color?
-
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. -
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. -
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.Hi there. You can set the
bgcolor
of the body element directly -<body bgcolor="#FFC9B8">
or you can create a css <style> for the page:
<html>
<head>
<style>
body {background-color: #FFC9B8;}
</style>
</head>
<body>
...
</body>
</html>Or, if you do want to set it in the server-side
Page_Load
, you can add anid
attribute andrunat="server"
to the <body> tag, then reference it server-side:<script runat="server">
void Page_Load(object sender, System.EventArgs e)
{
myPageBody.Attributes["bgcolor"] = "#FFC9B8";
}
</script>
<html>
<body id="myPageBody" runat="server">
...
</body>
</html> -
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.