469,934 Members | 2,092 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

Change BgColor of aspx page in code

How do I programatically change the background color of an aspx page in
code?

Is there something like Page.BgColor = "#FFFFFF" ?

For that matter, how do I access any of the DOCUMENT properties in code?

I am using Visual Studio 2003, building an ASP.NET web application using
VB.NET.

Thanks,,,,, Cliff
Nov 20 '05 #1
3 2734
* "Cliff Cavin" <Cl********@hotmail.com> scripsit:
How do I programatically change the background color of an aspx page in
code?

Is there something like Page.BgColor = "#FFFFFF" ?


ASP.NET group:

<news://msnews.microsoft.com/microsoft.public.dotnet.framework.aspnet>

Web interface:

<http://msdn.microsoft.com/newsgroups/default.asp?url=/newsgroups/loadframes.asp?icp=msdn&slcid=us&newsgroup=microso ft.public.dotnet.framework.aspnet>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Hi Cliff

Thanks for using Microsoft MSDN Managed Newsgroup. My name is Peter, and I
will be assisting you on this issue.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to modify the BgColor of
the Webform and wants to modify other similar document property.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think in Server-Side, i.e. code behind, if you wants to access the
BgColor, you may need to add attribute to the Body which is a
HtmlGenericControl control.

Here is a demo, you may have a try and let me know the result.
[ASPX]
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="TestAsp.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout" runat="server" id="bg">
<form id="Form1" method="post" runat="server">
<FONT face="Arial"></FONT>
</form>
</body>
</HTML>

[NOTE}
Set the body id to bg so that it can be used in code behind.

[CODEBEHIND]

Protected bg As System.Web.UI.HtmlControls.HtmlGenericControl
Private Sub Page_Load(sender As Object, e As System.EventArgs)
bg.Attributes.Add("BgColor", "#ff9933")
End Sub

For other properties, you may try the similar methods.

If you have any concern on this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #3
Cor
Hi Cliff,

As an alternative to the method from Peter,

You can do in the designer on the page a right click and than choose "Build
Style"
Than you can direct choose the background color of your Page.

I have to admit, the methode from Peter reaches more your question, but I
thought it was good to make you attent on this more in VS.studio.net 2003
build in standard webapproach method.

Cor
How do I programatically change the background color of an aspx page in
code?
Is there something like Page.BgColor = "#FFFFFF" ?
For that matter, how do I access any of the DOCUMENT properties in code?
I am using Visual Studio 2003, building an ASP.NET web application using
VB.NET.

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by RWD | last post: by
7 posts views Thread by Cliff Cavin | last post: by
1 post views Thread by Mirco | last post: by
1 post views Thread by Dmitry N.Ananyev | last post: by
6 posts views Thread by acord | last post: by
1 post views Thread by =?Utf-8?B?cm9kY2hhcg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.