Master Pages and Absolute Image URI's in HTML

A

Admin.TalkPC

Hi Guys

I have an ASP.NET project with a rough layout as shown below


Default.aspx
Login.aspx
Site.master
web.config
/IMAGES/Image1.jpg
/Image2.jpg
/Image3.jpg ...
/Secure/SecurePage1.aspx
/SecurePage2.aspx
/SecurePage3.aspx
/web.config


Loads of stuff left out, but that is the gist of it. All pages use the
Master Page, There are password protected pages held within the /Secure
folder.

Problem:

My master page uses HTML that includes bith <IMG> tags and Java Script
that manipulates the images in the /Images folder.

I cannot get the SRC attrbiute of the <IMG> tag to give me an image
that will display for both the "Default.aspx" and "SecurePage1.aspx".

My <IMG> tags look something like (Code from memory, not cut/paste)

<IMG src="/Images/image1.jpg" ... />

It seems that when I use the URI specification

<IMG src="Images/image1.jpg" ... />

The image is displayed in the Default.aspx only. But if I change it to


<IMG src="/Images/image1.jpg" ... />

the image is not displayed in the Default.aspx OR any of the pages in
the Secure folder.

I read that putting the "/" at the start will set the URI to be
relative to the root of the site, but I just cannot seem to get this to
work.

Could anyone point me in the direction of what may be my problem please
?

kind regards

Mike.

p.s.

There are NO ASP.NET Image Server side controls, it is all basic HTML
as spat out from Photoshop/GoLive. I would like this to remain if
possible, with just a minor URI change for the images.
 
R

Rad [Visual C# MVP]

Hey, try this:

<IMG src="<%= Page.ResolveUrl("~")%>/Images/image1.jpg" ... />
 
A

Admin.TalkPC

Thanks mate,

that works OK for the <IMG> Tags, but I also have Javascript
manipulating the images and the <% construct does not work in there.

Mike
 

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

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top