none
I am trying to make a website - Just to learn how to do it! But I have a Problem

    Question

  • I have created a Master Page with a header to which i have added an image.
    I have supplied the imageurl and it shows ok in the designer. But not in the browser!

    I have also added a menu and some pages all of which work ok except the one with a background image.Again the image wont show!

    I know that they are there because i set the Border width to 50 and then i can see just the borders but no image?

    Can anyone offer an explanation please this has me baffled!

    Thanks

    Mike
    Friday, December 23, 2005 6:56 AM

Answers

  • Congratulations on designing your first web site; you've run into the exact same problem I did when I started out: paths.

    Basically, the chances are you're using an absolute path to a file which the web server can't see. When developing/designing web sites, use a relative path.

    Quick example:

    Let's call the folder your web site files are saved to D:\My Site. This contains a directory named images, in which you have a logo file, say logo.gif.

    Meanwhile, back in D:\My Site, you've got your main index.htm file which is referencing the image. When it's copied to the web server, the path it uses needs to be relative in order that the image file can still be seen.

    Your image tag might look like:

    <img src="D:\My Site\images\logo.gif" />

    Instead, it needs to refer to the file in a relative (I keep using that word) manner, like this:

    <img src="images/logo.gif" />

    What this does is says, "look for a file called logo.gif, which is in a directory called images. I don't know exactly where that directory is, but it's in the same place as this file."

    Hope this sorts the problem.

    Saturday, December 24, 2005 4:22 AM

All replies

  • Congratulations on designing your first web site; you've run into the exact same problem I did when I started out: paths.

    Basically, the chances are you're using an absolute path to a file which the web server can't see. When developing/designing web sites, use a relative path.

    Quick example:

    Let's call the folder your web site files are saved to D:\My Site. This contains a directory named images, in which you have a logo file, say logo.gif.

    Meanwhile, back in D:\My Site, you've got your main index.htm file which is referencing the image. When it's copied to the web server, the path it uses needs to be relative in order that the image file can still be seen.

    Your image tag might look like:

    <img src="D:\My Site\images\logo.gif" />

    Instead, it needs to refer to the file in a relative (I keep using that word) manner, like this:

    <img src="images/logo.gif" />

    What this does is says, "look for a file called logo.gif, which is in a directory called images. I don't know exactly where that directory is, but it's in the same place as this file."

    Hope this sorts the problem.

    Saturday, December 24, 2005 4:22 AM
  • Thanks Rob,
    Yes you were right it was the path! but not quite for the same reason as you experienced.

    I checked the path in the HTML and it looked OK it was something like ImageUrl="~/App_Code/images/728x90.jpg"
    But it made me think why was the images folder under the App_code folder?
    I think i must have put it there but anyway i thought i'd move it to be directly under the website folder. I did this and changed the HTML to ImageUrl="~/images/728x90.jpg"  and it all worked fine.

    So thanks!

    Mike
    Saturday, December 24, 2005 5:38 AM