setting the page colour in web page.

Posted by Gokul under Regular Expressions on 12/27/2010 | Points: 10 | Views : 1241 | Status : [Member] | Replies : 4
Dear Friends
How to set the colour of the webpage. I ve created the application with the master page and few ordinary pages. How to set the page colour for the web pages.


Regards
Gokul.N

Thanks and Regards,
GokulNath Nithy.



Responses

Posted by: Chvrsri on: 12/27/2010 [Member] [Moderator] [MVP] Silver | Points: 25

Up
0
Down
Hi you can do this using this way

ASP Code:
<body runat="server" id="body">


Code Behind:
protected System.Web.UI.HtmlControls.HtmlGenericControl body;

...
string strColor =
System.Configuration.ConfigurationSettings.AppSett ings["bgColor"];
body.Attributes.Add("bgColor", strColor);



Can follow this link for more info

http://www.velocityreviews.com/forums/t123138-changing-the-background-color.html


Thanks,
Radha Srikanth

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gokul on: 12/27/2010 [Member] Starter | Points: 25

Up
0
Down
I am not clear . If i use body tag inside the page , an error is displaying that bodg tag is not permitted inside div tag. how to rectify it? U ve any other way to so?


Regards
Gokul.N


Thanks and Regards,
GokulNath Nithy.

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 1/6/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Try this link

http://www.beansoftware.com/ASP.NET-FAQ/Change-Page-Background.aspx

Thanks
Karthik
www.f5Debug.net

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 1/6/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
try this as well

try the code snippet below:



<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
<title>Untitled Page</title>

<script type="text/javascript" language="javascript">
function test()
{
var colorVal = "<%= color %>";
document.getElementById("<%=form1.ClientID%>").style.backgroundColor = colorVal ;
}
</script>

</head>
<body onload="test();">
<form id="form1" runat="server">
<div>
test<br />
test<br />
test<br />
test<br />
test<br />
test<br />
</div>
</form>
</body>
</html>



in code behind:



public partial class _Default : System.Web.UI.Page
{
string _color;
protected void Page_init(object sender, EventArgs e)
{
//get the color value from database here..
//i set here red as constant value;
color = "red";
}
public string color { get { return _color; } set { _color = value; } }

}


Thanks
Karthik
www.f5Debug.net

Gokul, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response