image path broken

Discussion in 'ASP .Net' started by SAL, May 18, 2007.

  1. SAL

    SAL Guest

    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
     
    SAL, May 18, 2007
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    >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
    >
     
    Kevin Spencer, May 18, 2007
    #2
    1. Advertising

  3. SAL

    SAL Guest

    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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    >>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
    >>

    >
    >
     
    SAL, May 18, 2007
    #3
  4. 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" <> wrote in message
    > news:...
    > > 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" <> wrote in message
    > > news:...
    > >>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
    > >>

    > >
    > >

    >
    >
    >
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, May 19, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. localhost

    Assembly Binding Path Broken?

    localhost, Oct 25, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    511
    Steven Cheng[MSFT]
    Oct 26, 2004
  2. Steven D'Aprano

    Why are "broken iterators" broken?

    Steven D'Aprano, Sep 21, 2008, in forum: Python
    Replies:
    8
    Views:
    673
  3. Cameron Simpson

    Re: Why are "broken iterators" broken?

    Cameron Simpson, Sep 22, 2008, in forum: Python
    Replies:
    0
    Views:
    600
    Cameron Simpson
    Sep 22, 2008
  4. Fredrik Lundh

    Re: Why are "broken iterators" broken?

    Fredrik Lundh, Sep 22, 2008, in forum: Python
    Replies:
    0
    Views:
    619
    Fredrik Lundh
    Sep 22, 2008
  5. Paweł Stawicki
    Replies:
    0
    Views:
    164
    Paweł Stawicki
    Jun 3, 2007
Loading...

Share This Page