473,385 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Changing Page bgColor from code

I need to be able to change the background color of a page from code. I
found an answer to this question in another forum from Peter Huang that said
that an id="bg" as follows...

<body MS_POSITIONING="GridLayout" runat="server" id="bg">

then we could do the following in our codebehind file....

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

However, I get the errror that bg is Private.

Is there a solution to this issue where bgcolor, and other attributes of the
document can be changed from codebehind code?
--
Regards,
Gary Blakely
Mar 11 '06 #1
6 1454
On Sat, 11 Mar 2006 11:01:06 -0800, GaryDean wrote:
I need to be able to change the background color of a page from code. I
found an answer to this question in another forum from Peter Huang that said
that an id="bg" as follows...

<body MS_POSITIONING="GridLayout" runat="server" id="bg">

then we could do the following in our codebehind file....

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

However, I get the errror that bg is Private.

Is there a solution to this issue where bgcolor, and other attributes of the
document can be changed from codebehind code?


I'm not sure what version of ASP.NET you're using, but if you're using 2.0,
and the document type is XHTML, then bgcolor is deprecated. You would
instead set the style background-color: #ff9933; instead. Something like
this (I haven't test this code, so the exact syntax may not be correct).

Dim style as string = bg.Attributes("style")
s = s & "background-color: #ff9933;"
bg.Attributes("style") = s

This, of course, assumes that there isn't already a background-color style
(though it would probalby still work). So you might have to add some code
to determine if there is already one, and replace it if there is.
Mar 11 '06 #2
There's been sample code to do that since ASP.NET 1.0.

See :
http://samples.gotdotnet.com/quickst.../cookies1.aspx
for a sample doing that with cookies.

and

http://samples.gotdotnet.com/quickst.../session1.aspx
for a sample doing it with session values.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Erik Funkenbusch" <er**@despam-funkenbusch.com> wrote in message
news:1n***************@funkenbusch.com...
On Sat, 11 Mar 2006 11:01:06 -0800, GaryDean wrote:
I need to be able to change the background color of a page from code. I
found an answer to this question in another forum from Peter Huang that said
that an id="bg" as follows...

<body MS_POSITIONING="GridLayout" runat="server" id="bg">

then we could do the following in our codebehind file....

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

However, I get the errror that bg is Private.

Is there a solution to this issue where bgcolor, and other attributes of the
document can be changed from codebehind code?


I'm not sure what version of ASP.NET you're using, but if you're using 2.0,
and the document type is XHTML, then bgcolor is deprecated. You would
instead set the style background-color: #ff9933; instead. Something like
this (I haven't test this code, so the exact syntax may not be correct).

Dim style as string = bg.Attributes("style")
s = s & "background-color: #ff9933;"
bg.Attributes("style") = s

This, of course, assumes that there isn't already a background-color style
(though it would probalby still work). So you might have to add some code
to determine if there is already one, and replace it if there is.

Mar 11 '06 #3
This is the small modification that u hav to do in the code:
instead of: "<body MS_POSITIONING="GridLayout" runat="server" id="bg">"
Just recode it to: "<body> <form id="bg" runat="server">
..........</form> </body>"
And the rest is same.
just like recoding it with the actual source id from html tags.

Mar 11 '06 #4
that doesn't work. the id in form already says id="Form1" and form1 is
unrecognized.

I forgot to indicate that I'm using 1.1 so I'll repost.

Thanks,
Gary

"Symphani" <sy******@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
This is the small modification that u hav to do in the code:
instead of: "<body MS_POSITIONING="GridLayout" runat="server" id="bg">"
Just recode it to: "<body> <form id="bg" runat="server">
.........</form> </body>"
And the rest is same.
just like recoding it with the actual source id from html tags.

Mar 11 '06 #5
oops. forgot to say I'm using 1.1. I'll repost

--
Regards,
Gary Blakely
"Erik Funkenbusch" <er**@despam-funkenbusch.com> wrote in message
news:1n***************@funkenbusch.com...
On Sat, 11 Mar 2006 11:01:06 -0800, GaryDean wrote:
I need to be able to change the background color of a page from code. I
found an answer to this question in another forum from Peter Huang that
said
that an id="bg" as follows...

<body MS_POSITIONING="GridLayout" runat="server" id="bg">

then we could do the following in our codebehind file....

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

However, I get the errror that bg is Private.

Is there a solution to this issue where bgcolor, and other attributes of
the
document can be changed from codebehind code?


I'm not sure what version of ASP.NET you're using, but if you're using
2.0,
and the document type is XHTML, then bgcolor is deprecated. You would
instead set the style background-color: #ff9933; instead. Something like
this (I haven't test this code, so the exact syntax may not be correct).

Dim style as string = bg.Attributes("style")
s = s & "background-color: #ff9933;"
bg.Attributes("style") = s

This, of course, assumes that there isn't already a background-color style
(though it would probalby still work). So you might have to add some code
to determine if there is already one, and replace it if there is.

Mar 11 '06 #6
Hi Gary,

We've found your new reposted thread in this group and posted suggestion
there. If you feel it convenient that we continue to discuss there, please
feel free to post in that thread.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Mar 13 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: Arthur Shapiro | last post by:
I'm the webmaster for a recreational organization. As part of one page of the site, I have an HTML "Calendar at a Glance" of the organization's events for the month. It's a simple table of a...
12
by: GaryDean | last post by:
In the original post I failed so indicate that I am using framework 1.1....... I need to be able to change the background color of a page from code. I found an answer to this question in...
8
by: Radx | last post by:
Here in my web application, I have a data entry page with serval controls. Some of the controls have autopostback is set true. But the problem is when two or more people are entering data at the...
3
by: Bill | last post by:
I'm using the POST method to submit a simple form html page with yes/no and checkbox fields to an asp response page which stores the values in a new dim string, then uses it to build a new table...
1
by: rbinington | last post by:
Hi, I am trying to write a DNN module that has the ability to insert articles into an article repository. I want the users to be able to move pages around and enter text into the FCKEditor. I...
2
by: nick0123 | last post by:
Newbie-ish here... I have made a simple database in MS Access 2003 listing sports teams, their playing dates, opposition venues etc. The database has six tables, one for each sport. Exporting...
3
by: kang jia | last post by:
hi i am doing reply page for forum, users can reply for the specific topic they would like to reply. Firstly of all, when click the topic name in topic page. i will redirect them to reply page....
4
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters...
2
by: suganya | last post by:
Hi I have a master page with <TD> columns defined in the table as <td bgcolor="#518643"> (which means bgcolor="green"). In one of my content pages, I have a dropdown with values such as blue,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.