473,385 Members | 1,569 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.

Help: Changing background color dynamically

I am trying to change some webform's background color based on a value in my
web.config file.

This is how I am doing it:
' set background color based on web.config setting
Dim Body As New HtmlGenericControl
Body = CType(Page.Controls(1), HtmlGenericControl)
Body.Attributes("bgcolor") =
ConfigurationSettings.AppSettings("BackgroundColor ")

For most pages in my web app it works FINE. But for some new pages it is not
working.
For the ones that work, page.Controls(1).tostring is equal to
"System.Web.UI.HtmlControls.HtmlGenericControl ".
For the ones that don't work it's equal to
"System.Web.UI.HtmlControls.HtmlForm" and the CType fails.

Any ideas?

Nov 18 '05 #1
7 2771
If I was you, I'd be using the "Style" to this sort of thing, heres an
example I did a while ago...
objCell.Style.Add("color","Red");

"VB Programmer" <gr*********@go-intech.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I am trying to change some webform's background color based on a value in my web.config file.

This is how I am doing it:
' set background color based on web.config setting
Dim Body As New HtmlGenericControl
Body = CType(Page.Controls(1), HtmlGenericControl)
Body.Attributes("bgcolor") =
ConfigurationSettings.AppSettings("BackgroundColor ")

For most pages in my web app it works FINE. But for some new pages it is not working.
For the ones that work, page.Controls(1).tostring is equal to
"System.Web.UI.HtmlControls.HtmlGenericControl ".
For the ones that don't work it's equal to
"System.Web.UI.HtmlControls.HtmlForm" and the CType fails.

Any ideas?

Nov 18 '05 #2
Why don't you use CSS classes...
"VB Programmer" <gr*********@go-intech.com> a écrit dans le message de news:
#i**************@TK2MSFTNGP11.phx.gbl...
I am trying to change some webform's background color based on a value in my web.config file.

This is how I am doing it:
' set background color based on web.config setting
Dim Body As New HtmlGenericControl
Body = CType(Page.Controls(1), HtmlGenericControl)
Body.Attributes("bgcolor") =
ConfigurationSettings.AppSettings("BackgroundColor ")

For most pages in my web app it works FINE. But for some new pages it is not working.
For the ones that work, page.Controls(1).tostring is equal to
"System.Web.UI.HtmlControls.HtmlGenericControl ".
For the ones that don't work it's equal to
"System.Web.UI.HtmlControls.HtmlForm" and the CType fails.

Any ideas?

Nov 18 '05 #3
Any example online? I don't know what CSS classes are, but would like to
find out more.

"(Laurent Jordi)" <la*****@ezlogic.mc> wrote in message
news:us**************@TK2MSFTNGP12.phx.gbl...
Why don't you use CSS classes...
"VB Programmer" <gr*********@go-intech.com> a écrit dans le message de news: #i**************@TK2MSFTNGP11.phx.gbl...
I am trying to change some webform's background color based on a value
in my
web.config file.

This is how I am doing it:
' set background color based on web.config setting
Dim Body As New HtmlGenericControl
Body = CType(Page.Controls(1), HtmlGenericControl)
Body.Attributes("bgcolor") =
ConfigurationSettings.AppSettings("BackgroundColor ")

For most pages in my web app it works FINE. But for some new pages it is

not
working.
For the ones that work, page.Controls(1).tostring is equal to
"System.Web.UI.HtmlControls.HtmlGenericControl ".
For the ones that don't work it's equal to
"System.Web.UI.HtmlControls.HtmlForm" and the CType fails.

Any ideas?


Nov 18 '05 #4
It's a internet dev basic...

You have to create a style sheet
with
..withBorders {
BORDER: black thin solid
}

Link it to your page

in your html tag add class="classname"

like

<IMG SRC="blablabla" class="withBorders" />

"VB Programmer" <gr*********@go-intech.com> a écrit dans le message de news:
O2**************@TK2MSFTNGP12.phx.gbl...
Any example online? I don't know what CSS classes are, but would like to
find out more.

"(Laurent Jordi)" <la*****@ezlogic.mc> wrote in message
news:us**************@TK2MSFTNGP12.phx.gbl...
Why don't you use CSS classes...
"VB Programmer" <gr*********@go-intech.com> a écrit dans le message de

news:
#i**************@TK2MSFTNGP11.phx.gbl...
I am trying to change some webform's background color based on a value in
my
web.config file.

This is how I am doing it:
' set background color based on web.config setting
Dim Body As New HtmlGenericControl
Body = CType(Page.Controls(1), HtmlGenericControl)
Body.Attributes("bgcolor") =
ConfigurationSettings.AppSettings("BackgroundColor ")

For most pages in my web app it works FINE. But for some new pages it

is not
working.
For the ones that work, page.Controls(1).tostring is equal to
"System.Web.UI.HtmlControls.HtmlGenericControl ".
For the ones that don't work it's equal to
"System.Web.UI.HtmlControls.HtmlForm" and the CType fails.

Any ideas?



Nov 18 '05 #5
not classes, CSS (Cascading Style Sheet).
Plenty of samples out there, do a MS search or google.
It's a function of html really.

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"VB Programmer" <gr*********@go-intech.com> wrote in message
news:O2**************@TK2MSFTNGP12.phx.gbl...
Any example online? I don't know what CSS classes are, but would like to
find out more.

"(Laurent Jordi)" <la*****@ezlogic.mc> wrote in message
news:us**************@TK2MSFTNGP12.phx.gbl...
Why don't you use CSS classes...
"VB Programmer" <gr*********@go-intech.com> a écrit dans le message de

news:
#i**************@TK2MSFTNGP11.phx.gbl...
I am trying to change some webform's background color based on a value in
my
web.config file.

This is how I am doing it:
' set background color based on web.config setting
Dim Body As New HtmlGenericControl
Body = CType(Page.Controls(1), HtmlGenericControl)
Body.Attributes("bgcolor") =
ConfigurationSettings.AppSettings("BackgroundColor ")

For most pages in my web app it works FINE. But for some new pages it

is not
working.
For the ones that work, page.Controls(1).tostring is equal to
"System.Web.UI.HtmlControls.HtmlGenericControl ".
For the ones that don't work it's equal to
"System.Web.UI.HtmlControls.HtmlForm" and the CType fails.

Any ideas?



Nov 18 '05 #6
Awesome tutorials here: http://www.w3schools.com/

Thanks!

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:ea****************@TK2MSFTNGP12.phx.gbl...
not classes, CSS (Cascading Style Sheet).
Plenty of samples out there, do a MS search or google.
It's a function of html really.

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"VB Programmer" <gr*********@go-intech.com> wrote in message
news:O2**************@TK2MSFTNGP12.phx.gbl...
Any example online? I don't know what CSS classes are, but would like to
find out more.

"(Laurent Jordi)" <la*****@ezlogic.mc> wrote in message
news:us**************@TK2MSFTNGP12.phx.gbl...
Why don't you use CSS classes...
"VB Programmer" <gr*********@go-intech.com> a écrit dans le message de news:
#i**************@TK2MSFTNGP11.phx.gbl...
> I am trying to change some webform's background color based on a
value in
my
> web.config file.
>
> This is how I am doing it:
> ' set background color based on web.config setting
> Dim Body As New HtmlGenericControl
> Body = CType(Page.Controls(1), HtmlGenericControl)
> Body.Attributes("bgcolor") =
> ConfigurationSettings.AppSettings("BackgroundColor ")
>
> For most pages in my web app it works FINE. But for some new pages

it is not
> working.
> For the ones that work, page.Controls(1).tostring is equal to
> "System.Web.UI.HtmlControls.HtmlGenericControl ".
> For the ones that don't work it's equal to
> "System.Web.UI.HtmlControls.HtmlForm" and the CType fails.
>
> Any ideas?
>
>
>



Nov 18 '05 #7
The problem is not with trying to change the background color. You
are getting an error on this line...

Body = CType(Page.Controls(1), HtmlGenericControl)

As you said, the pages that have the problem are HTMLForm controls.
You are getting an error trying to Convert a HTMLForm to a
HTMLGenericControl. I would suggest casting to a "Control" type

Neil

"VB Programmer" <gr*********@go-intech.com> wrote in message news:<#i**************@TK2MSFTNGP11.phx.gbl>...
I am trying to change some webform's background color based on a value in my
web.config file.

This is how I am doing it:
' set background color based on web.config setting
Dim Body As New HtmlGenericControl
Body = CType(Page.Controls(1), HtmlGenericControl)
Body.Attributes("bgcolor") =
ConfigurationSettings.AppSettings("BackgroundColor ")

For most pages in my web app it works FINE. But for some new pages it is not
working.
For the ones that work, page.Controls(1).tostring is equal to
"System.Web.UI.HtmlControls.HtmlGenericControl ".
For the ones that don't work it's equal to
"System.Web.UI.HtmlControls.HtmlForm" and the CType fails.

Any ideas?

Nov 18 '05 #8

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

Similar topics

3
by: Billy | last post by:
Hello, I'm having a problem dynamically changing the color of a table background. I'm not sure exactly how to word this, but I'll give an example. I have a function called greentored(propname)...
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...
6
by: Nancy Carter | last post by:
I'm trying to set the background color of a frameset to black. The following code doesn't work in either IE 6.0 or Firefox. Any ideas why? <frameset bgcolor="#000000" frameborder="0" border="0"...
1
by: Omar Llanos | last post by:
How can I change the background color of an MDI form? I read in msdn that it takes the background of windows (and not the BackColor) but I wanted to really make sure. I know that in VC it can be...
0
by: Tom | last post by:
Hi I have a ListBox control of my asp.net web page. I want to set the value of the style property of the ListItem to a specific background color. I have tried this but no success: //li is...
1
by: Ben Pursley | last post by:
If a date in one of the cells of my Datagrid is today's date, I would like that entire row to be highlighted by different background color. Is this possible. ..how? Thanks for the help!
8
by: Bosconian | last post by:
I have two multiple select inputs. Initially the first contains a bunch of items and the second is empty. Using a common method, I move items back and forth by double clicking on them. This...
3
by: 2good2b | last post by:
Is there a way to change the background color dynamically, when the color is defined at a CSS stylesheet? (tried document.bgcolor and this.style.background-color) Thanks
1
by: printline | last post by:
Hi' I have a problem with changing the background color in a table cell when i click on the content in the cell. Here is my code: <script type="text/javascript"> var ie = document.all...
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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.