Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > image path broken

Reply
Thread Tools

image path broken

 
 
SAL
Guest
Posts: n/a
 
      05-18-2007
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


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      05-18-2007
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

"SAL" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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
>



 
Reply With Quote
 
 
 
 
SAL
Guest
Posts: n/a
 
      05-18-2007
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.


"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
> "SAL" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>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
>>

>
>



 
Reply With Quote
 
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
Posts: n/a
 
      05-19-2007
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
--
Milosz


"SAL" wrote:

> 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.
>
>
> "Kevin Spencer" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> > "SAL" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >>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
> >>

> >
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why are "broken iterators" broken? Steven D'Aprano Python 8 09-28-2008 09:19 PM
Re: Why are "broken iterators" broken? Fredrik Lundh Python 0 09-22-2008 04:32 PM
Re: Why are "broken iterators" broken? Cameron Simpson Python 0 09-22-2008 04:32 AM
[RoR] Path for mongrel broken after moving eclipse workspace PaweĊ‚ Stawicki Ruby 0 06-03-2007 10:08 PM
Assembly Binding Path Broken? localhost ASP .Net 1 10-26-2004 03:40 AM



Advertisments