change background image in code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to change the background image of the html page within code based on
the users selection.
I'm trying to use this in the page onload even

response.write("<body background=' & dataitem>")

but i can't get it to work. if i hard code the dataitem in it will change
but i need it to work with the item being passed in.
 
Add javascript variable backgroundString and function onLoad() to the <head>
section:

var backgroundString;
function onLoad(){document.body.background=backgroundString}

In the html view write <body onload='onLoad()'>

In the code-behind write (c#)
Response.Write(String.Format("<script>backgroundString={0}<script>",
dataitem));

Eliyahu
 
Back
Top