473,412 Members | 2,012 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,412 software developers and data experts.

Changing CSS Background Dynamically (VB)

Hi

Currently I am setting the background image of my page by using the
following code:

<style type="text/css">
BODY { BACKGROUND-IMAGE: url(myimage.jpg) }
</style>

What I would like to do is change the background image dynamically. My guess
was to use the Attributes.Add function, but while I can do something like
Button1.Attributes.Add, I can't figure out how to apply attributes to the
entire page.

Am I on the right track or should I being doing something else?

Thanks
Chris

Nov 18 '05 #1
4 3769
Don't worry, I figured it out :)

Chris

On 30/8/04 11:04 AM, in article BD***************@spam.me, "Chris Mahoney"
<do**@spam.me> wrote:
Hi

Currently I am setting the background image of my page by using the
following code:

<style type="text/css">
BODY { BACKGROUND-IMAGE: url(myimage.jpg) }
</style>

What I would like to do is change the background image dynamically. My guess
was to use the Attributes.Add function, but while I can do something like
Button1.Attributes.Add, I can't figure out how to apply attributes to the
entire page.

Am I on the right track or should I being doing something else?

Thanks
Chris


Nov 18 '05 #2
On Mon, 30 Aug 2004 11:04:00 +1200, Chris Mahoney <do**@spam.me> wrote:
Hi

Currently I am setting the background image of my page by using the
following code:

<style type="text/css">
BODY { BACKGROUND-IMAGE: url(myimage.jpg) }
</style>

What I would like to do is change the background image dynamically. My
guess
was to use the Attributes.Add function, but while I can do something like
Button1.Attributes.Add, I can't figure out how to apply attributes to the
entire page.

Am I on the right track or should I being doing something else?

Thanks
Chris


You can make the STYLE tag a server control and then alter it from
code-behind (you can do this with just about any tag in the doc).

My example is changing background-color:
<!-- add an id="" and runat="server" to the tag -->
<style id="hgcStyle" runat="server">
.tb { BACKGROUND-COLOR: red }
</style>

code-behind:
'//you have to declare the control variable yourself, just like the other
controls
Protected WithEvents hgcStyle As
System.Web.UI.HtmlControls.HtmlGenericControl

'//now you can access the tag, e.g.
hgcStyle.InnerText = ".tb {background-color: " & TextBox1.Text & "}"

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #3
On Mon, 30 Aug 2004 13:50:38 +1200, Chris Mahoney <do**@spam.me> wrote:
Don't worry, I figured it out :)

Chris


TOO LATE! Reply is coming :-)

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #4

"Chris Mahoney" <do**@spam.me> wrote in message
news:BD58E12E.6FF%do**@spam.me...
Don't worry, I figured it out :)


OK, so you figured it out. How nice for you. How about sharing the solution
with the group, so that when someone else has a similar problem and searches
groups.google.com, they won't just come across a thread that promises a
solution but ends in nothing but a smiley?

We're all in this together, amigo.

Tom Dacon
Dacon Software Consulting


Nov 18 '05 #5

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)...
2
by: Dominic Myers | last post by:
Hi there, wondered if someone could point me to an appropriate tutorial or offer advice on the following problem? I've got a web page which uses lots of divs to position the content of the...
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...
7
by: VB Programmer | last post by:
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...
5
by: Jerry Camel | last post by:
I am interacting with an OCX on the client side. In the Onload event of the page, I am checking a property of the OCX: Is the port open or closed. If the port is open, I want a certain image to...
5
by: Tascien | last post by:
I was able to build an asp page dynamically depending on the question that the user answered through the online wizard... I think i can dynamically also create '.vb' or '.aspx' dynamically...
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
2
by: Jason_SanDiego2006 | last post by:
Hello all, Hang with me, I'm a little new. I'm working on a web application in C# using ASP.NET 2.0 The goal of my application is to have pages whose styles can be dynamically changed based...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.