change background image in code

Discussion in 'ASP .Net' started by =?Utf-8?B?TWlrZQ==?=, Sep 27, 2004.

  1. 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.
     
    =?Utf-8?B?TWlrZQ==?=, Sep 27, 2004
    #1
    1. Advertisements

  2. 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

    "Mike" <> wrote in message
    news:...
    > 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.
    >
     
    Eliyahu Goldin, Sep 28, 2004
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Johansen

    How to change background image ??

    Thomas Johansen, Feb 23, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    9,616
  2. Bobofrut

    How to change Background Image

    Bobofrut, Feb 27, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    657
    Bobofrut
    Feb 27, 2004
  3. EMW
    Replies:
    2
    Views:
    4,676
    Eliyahu Goldin
    Nov 7, 2005
  4. Replies:
    1
    Views:
    5,599
    Rhino
    May 2, 2006
  5. Israel Richner

    Change background image of asp:button

    Israel Richner, Jan 8, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    7,744
    Israel Richner
    Jan 8, 2007
  6. jc
    Replies:
    3
    Views:
    2,039
  7. jc
    Replies:
    1
    Views:
    1,624
    Neredbojias
    Mar 19, 2008
  8. Dj Frenzy
    Replies:
    3
    Views:
    583
    Robert
    Feb 10, 2004
Loading...