Referencing root document in <IMG> tag...

  • Thread starter Thread starter Bobby Edward
  • Start date Start date
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!
 
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
 
Back
Top