Connecting Tech Pros Worldwide Forums | Help | Site Map

Master Pages and Absolute Image URI's in HTML

Admin.TalkPC@googlemail.com
Guest
 
Posts: n/a
#1: Nov 30 '06
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 <IMGtags and Java Script
that manipulates the images in the /Images folder.

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

My <IMGtags 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.


Rad [Visual C# MVP]
Guest
 
Posts: n/a
#2: Nov 30 '06

re: Master Pages and Absolute Image URI's in HTML


Hey, try this:

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

On 30 Nov 2006 00:52:06 -0800, Admin.TalkPC@googlemail.com wrote:
Quote:
>?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 <IMGtags and Java Script
>that manipulates the images in the /Images folder.
>
>I cannot get the SRC attrbiute of the <IMGtag to give me an image
>that will display for both the "Default.aspx" and "SecurePage1.aspx".
>
>My <IMGtags 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.
--

Bits.Bytes.
http://bytes.thinkersroom.com
Admin.TalkPC@googlemail.com
Guest
 
Posts: n/a
#3: Nov 30 '06

re: Master Pages and Absolute Image URI's in HTML


Thanks mate,

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

Mike


Rad [Visual C# MVP] wrote:
Quote:
Hey, try this:
>
<IMG src="<%= Page.ResolveUrl("~")%>/Images/image1.jpg" ... />
>
On 30 Nov 2006 00:52:06 -0800, Admin.TalkPC@googlemail.com wrote:
>
Quote:
?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 <IMGtags and Java Script
that manipulates the images in the /Images folder.

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

My <IMGtags 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.
--
>
Bits.Bytes.
http://bytes.thinkersroom.com
Rad [Visual C# MVP]
Guest
 
Posts: n/a
#4: Dec 1 '06

re: Master Pages and Absolute Image URI's in HTML


Maybe if you could post an example of the javascript....

On 30 Nov 2006 12:35:43 -0800, Admin.TalkPC@googlemail.com wrote:
Quote:
>Thanks mate,
>
>that works OK for the <IMGTags, but I also have Javascript
>manipulating the images and the <% construct does not work in there.
>
>Mike
>
>
>Rad [Visual C# MVP] wrote:
Quote:
>Hey, try this:
>>
><IMG src="<%= Page.ResolveUrl("~")%>/Images/image1.jpg" ... />
>>
>On 30 Nov 2006 00:52:06 -0800, Admin.TalkPC@googlemail.com wrote:
>>
Quote:
>?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 <IMGtags and Java Script
>that manipulates the images in the /Images folder.
>
>I cannot get the SRC attrbiute of the <IMGtag to give me an image
>that will display for both the "Default.aspx" and "SecurePage1.aspx".
>
>My <IMGtags 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.
>--
>>
>Bits.Bytes.
>http://bytes.thinkersroom.com
--

Bits.Bytes.
http://bytes.thinkersroom.com
Closed Thread