How to change the background image dynamicly?

E

EMW

For my page I have created two backgrounds.
On startup is uses image1 and when the user clicks on a linkbutton it should
use image2.
Here is were problem is.
I cannot find how to do this.
I can set the background to image1 and then open the page in IE, but how can
I swap it to image 2 programmaticly?

There is no style property and als the backgroundimage property isn't there.

I'm using ASP2.NET and visual basic.

rg.
Eric
 
K

Karl Seguin

There are a couple ways, but probably the one I like the most is to simply
add a runat="Server" to the body tag

<body id="body" runat="server">
....
</body>


then declare it in your codebehind,

protected body as HtmlGenericControl

and you can then do thigns like

body.Styles.Add("background-image", "url('image2.gif'");

or something
 
E

Eliyahu Goldin

Eric,

This can be easily done with a client-side onclick event. You can set it up
in the server-side code:

myLinkButton.Attributes("onclick") =
"window.document.body.background='image2.gif'"

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top