Problem setting css style using relative path

Discussion in 'ASP .Net' started by PeterKellner, Jul 29, 2006.

  1. PeterKellner

    PeterKellner Guest

    I'm having trouble setting a background style in a master page. The
    declaration in the master page looks like this:

    <div id="header_image" runat="server" style="background: transparent
    url(images/bg_header.jpg) repeat-x scroll 0% 0%;;cursor: pointer;">

    </div>

    I tried adding runat="server" as well as changing the url to
    ~/images/bg_head.jpg but that didn't work.

    Any suggestion on how to make the bg_header.jpg work on a master that
    can be referended from aspx pages in subdirectories?

    Thanks
    Peter Kellner
    http://peterkellner.net
     
    PeterKellner, Jul 29, 2006
    #1
    1. Advertising

  2. ~ is resolved using ResolveClientUrl(). As there is nothing in the CSS that
    uses this routine, it will fail.

    A couple of solutions.

    1. Create the master page for the upper level and then another for indention
    (a level off root)

    2. Create the image link from web root, which means, for virtual
    directories, you use the name of the virtual directory in the link. This
    works, although it is not too elegant.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    *************************************************
    Think Outside the Box!
    *************************************************
    "PeterKellner" <> wrote in message
    news:...
    > I'm having trouble setting a background style in a master page. The
    > declaration in the master page looks like this:
    >
    > <div id="header_image" runat="server" style="background: transparent
    > url(images/bg_header.jpg) repeat-x scroll 0% 0%;;cursor: pointer;">
    >
    > </div>
    >
    > I tried adding runat="server" as well as changing the url to
    > ~/images/bg_head.jpg but that didn't work.
    >
    > Any suggestion on how to make the bg_header.jpg work on a master that
    > can be referended from aspx pages in subdirectories?
    >
    > Thanks
    > Peter Kellner
    > http://peterkellner.net
     
    msnews.microsoft.com, Jul 29, 2006
    #2
    1. Advertising

  3. PeterKellner

    PeterKellner Guest

    On Sat, 29 Jul 2006 16:03:25 -0500, "msnews.microsoft.com"
    <> wrote:

    >~ is resolved using ResolveClientUrl(). As there is nothing in the CSS that
    >uses this routine, it will fail.
    >
    >A couple of solutions.
    >
    >1. Create the master page for the upper level and then another for indention
    >(a level off root)
    >
    >2. Create the image link from web root, which means, for virtual
    >directories, you use the name of the virtual directory in the link. This
    >works, although it is not too elegant.


    Hi,

    I don't quite understand what you mean by #2. Are you suggesting
    spelling out the domain name in the css file? If so, I think that
    would mean I'd have to change that each time I moved from one domain
    to another (like testing to non-testing).

    If you could explain, that would be a great help.
    Peter Kellner
    http://peterkellner.net
     
    PeterKellner, Jul 30, 2006
    #3
    1. Advertising

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. Matt
    Replies:
    3
    Views:
    19,726
    Sudsy
    Jul 8, 2004
  2. Thomas Guettler
    Replies:
    3
    Views:
    792
    Andrei
    Oct 27, 2003
  3. Oren
    Replies:
    1
    Views:
    575
    Michael D. Ober
    Apr 29, 2007
  4. Ken Varn
    Replies:
    0
    Views:
    538
    Ken Varn
    Apr 26, 2004
  5. Nigel Wilkinson
    Replies:
    2
    Views:
    422
    Nigel Wilkinson
    Jul 25, 2005
Loading...

Share This Page