Referencing root document in <IMG> tag...


B

Bobby Edward

I have a subdirectory with an aspx page that references a master file
located in the root.

In the master file template I reference a logo/image that is in
<root>/resources...
<img alt="logo" src="./resources/logo.png" />

For some reason when I pull up the page in the subdirectory it only shows
the alt tag because i think it can't find the png. Any idea why?

Other references used in the master file template are ok, such as...
<asp:Hyperlink runat="server"
NavigateUrl="./register.aspx">Register</asp:Hyperlink>

It finds the register.aspx in the <root> of the website.

Can you help me? Thanks!
 
Ad

Advertisements

G

Guest

I have a subdirectory with an aspx page that references a master file
located in the root.

In the master file template I reference a logo/image that is in
<root>/resources...
<img alt="logo" src="./resources/logo.png" />

For some reason when I pull up the page in the subdirectory it only shows
the alt tag because i think it can't find the png.  Any idea why?

Other references used in the master file template are ok, such as...
<asp:Hyperlink runat="server"
NavigateUrl="./register.aspx">Register</asp:Hyperlink>

It finds the register.aspx in the <root> of the website.

Can you help me?  Thanks!

Because Hyperlink is a server control, and img is an html tag. Calling
this

<img alt="logo" src="./resources/logo.png" />

from the http://root/subdir/page.aspx would call an image from
http://root/subdir/resources/logo.png

If your master is always in the root, there is no reason to use "." in
the url.

Use this

<img alt="logo" src="/resources/logo.png" />

to tell to all content pages that the image location is in the <root>/
resources

Hope this helps
 
Ad

Advertisements


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

Top