image path broken

S

SAL

I know there are probably some posts on this but I can't find any at the
moment.

I'm using VS 2005 on XP sp2.

I'm using a master page and I have an image that I need to show but the path
never really works correctly for all pages in the site.

For instance, I have an Image folder with my image in it.
My master page is in the Master folder, my default.aspx page is in the root
of the sit and most of my other pages are in their own folders.
So, when I do this:

<img src=../Images/img.jpg

the image maps correctly for every page that has it's own folder but the
default.aspx for the main site breaks this path. Is there a way to map this
thing correctly?

Thanks

S
 
K

Kevin Spencer

The easiset way is to use an ASP.Net Image Control. Otherwise, you will have
to either use an absolute URL, which may cause problems on your dev server,
or use your own code to get the correct URL for the image.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
S

SAL

Thanks Kevin.
I needed the OnClick event which the asp:image control didn't support.
So, I just inserted the following into the HTML


src="<% = Request.ApplicationPath %>/Restofpath/image.gif"

It's not WISIWIG but it does work. Sucks to not be able to use the WISIWIG
but oh well.
 
G

Guest

Hi SAL,

No need to use Request.Application path. There is a special method every
control exposes called ResolveUrl (Image control uses it internally)

<img src="<%= ResolveUrl("~/Images/image.gif") >%> />

Regards
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top