Setting background color in asp.net form
-
Hi there. One approach would be to assign the "
runat='server'
" attribute and anid
attribute to the html literal<body>
tag. Then in code you can set thebgColor
attribute based on the <body> tag'sid
to dynamically change the background color.<%@Page language="C#" %>
<script runat="server">
void Page_Load(Object o, EventArgs e)
{
// dynamically change the background color
// of the page
pageBodyTag.Attributes["bgColor"]="#D0D0B8";
}
</script><html>
<head>
</head><body id="pageBodyTag" runat="server"> <h3>Background Color on Page</h3> <p>Isn't this fun?</p> </body>
</html>
-
Hi there. One approach would be to assign the "
runat='server'
" attribute and anid
attribute to the html literal<body>
tag. Then in code you can set thebgColor
attribute based on the <body> tag'sid
to dynamically change the background color.<%@Page language="C#" %>
<script runat="server">
void Page_Load(Object o, EventArgs e)
{
// dynamically change the background color
// of the page
pageBodyTag.Attributes["bgColor"]="#D0D0B8";
}
</script><html>
<head>
</head><body id="pageBodyTag" runat="server"> <h3>Background Color on Page</h3> <p>Isn't this fun?</p> </body>
</html>
-
Thanks a lot, as a newbie I´d never get it to work, with your Page_Load overwrite but > and then having a GetColor() in my page class worked. You got me on the right track. Thanks a lot Jørgen Granborg
I like your idea better. Glad you got figured it out.