By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 995 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

Help: Changing background color dynamically

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.