Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Image URL Rendering Incorrectly

Image URL Rendering Incorrectly

Scheduled Pinned Locked Moved ASP.NET
csharpsysadminquestion
21 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Guffa

    That's a bit unexpected. You said that the ~ wasn't being set to the virtual directory, but you never said what did happen to it? --- b { font-weight: normal; }

    M Offline
    M Offline
    Michael Flanakin
    wrote on last edited by
    #7

    The relative URL is returned. My page is http://localhost/some/page.aspx and the rendered image path is http://localhost/some/Images/Edit.gif. Michael Flanakin Web Log

    1 Reply Last reply
    0
    • M Michael Flanakin

      I have a simple Image control on a web form that's not displaying the correct image path. I tried copying the code from another page that works, but it still isn't rendering the correct URL. For some reason, the "~/" isn't being set to the virtual directory. Does anyone have any ideas why this might be happening?

      <asp:Image runat="server"
      alternatetext="Edit"
      imageurl="~/Images/Edit.gif" />

      Michael Flanakin Web Log

      I Offline
      I Offline
      Ista
      wrote on last edited by
      #8

      well if its \\webroot\pages\page.aspx and the image is \\webroot\images\image.jpeg then use ..\images\image.gif or is this image dynami9c inside the repeater? 1 line of code equals many bugs. So don't write any!!

      M 1 Reply Last reply
      0
      • I Ista

        well if its \\webroot\pages\page.aspx and the image is \\webroot\images\image.jpeg then use ..\images\image.gif or is this image dynami9c inside the repeater? 1 line of code equals many bugs. So don't write any!!

        M Offline
        M Offline
        Michael Flanakin
        wrote on last edited by
        #9

        Well, it's not that easy. This control could be on any page, so that's not an option. And, no, the image isn't dynamic (other than it's visibility). Michael Flanakin Web Log

        I 1 Reply Last reply
        0
        • M Michael Flanakin

          Well, it's not that easy. This control could be on any page, so that's not an option. And, no, the image isn't dynamic (other than it's visibility). Michael Flanakin Web Log

          I Offline
          I Offline
          Ista
          wrote on last edited by
          #10

          Could you allow the user to pick the path? 1 line of code equals many bugs. So don't write any!!

          M 1 Reply Last reply
          0
          • I Ista

            Could you allow the user to pick the path? 1 line of code equals many bugs. So don't write any!!

            M Offline
            M Offline
            Michael Flanakin
            wrote on last edited by
            #11

            No. There's an option to use URL rewriting, which would pretty much knock any ability to get it relatively out of the water. The only real option is to use a root-relative path. I'm really wanting to know what's going on and why it doesn't work, more than anything. I've never seen anything like this before. Michael Flanakin Web Log

            I 1 Reply Last reply
            0
            • M Michael Flanakin

              No. There's an option to use URL rewriting, which would pretty much knock any ability to get it relatively out of the water. The only real option is to use a root-relative path. I'm really wanting to know what's going on and why it doesn't work, more than anything. I've never seen anything like this before. Michael Flanakin Web Log

              I Offline
              I Offline
              Ista
              wrote on last edited by
              #12

              Is it possible that the data source doesn't have any rows? I doubt it has anything to do with the virtual directory. Unless the virtual is pointing to somewhere else. Maybe use a response.write to show the path. 1 line of code equals many bugs. So don't write any!!

              M 1 Reply Last reply
              0
              • I Ista

                Is it possible that the data source doesn't have any rows? I doubt it has anything to do with the virtual directory. Unless the virtual is pointing to somewhere else. Maybe use a response.write to show the path. 1 line of code equals many bugs. So don't write any!!

                M Offline
                M Offline
                Michael Flanakin
                wrote on last edited by
                #13

                This is all in the ASCX file, and yes, there is data. The image wouldn't even be displayed if there wasn't because the image is in the Repeater's ItemTemplate. Michael Flanakin Web Log

                I 1 Reply Last reply
                0
                • M Michael Flanakin

                  This is all in the ASCX file, and yes, there is data. The image wouldn't even be displayed if there wasn't because the image is in the Repeater's ItemTemplate. Michael Flanakin Web Log

                  I Offline
                  I Offline
                  Ista
                  wrote on last edited by
                  #14

                  Thought that was what we were discussing:confused: 1 line of code equals many bugs. So don't write any!!

                  M 1 Reply Last reply
                  0
                  • I Ista

                    Thought that was what we were discussing:confused: 1 line of code equals many bugs. So don't write any!!

                    M Offline
                    M Offline
                    Michael Flanakin
                    wrote on last edited by
                    #15

                    Where are you suggesting I put a Response.Write()? Since this is all automatically done in .NET, I don't think this would get me anywhere. Michael Flanakin Web Log

                    I 1 Reply Last reply
                    0
                    • M Michael Flanakin

                      Where are you suggesting I put a Response.Write()? Since this is all automatically done in .NET, I don't think this would get me anywhere. Michael Flanakin Web Log

                      I Offline
                      I Offline
                      Ista
                      wrote on last edited by
                      #16

                      The reason I said that is maybe where the root is, is different. By outputting it you could find out if its pointing to somewhere else. 1 line of code equals many bugs. So don't write any!!

                      M 1 Reply Last reply
                      0
                      • I Ista

                        The reason I said that is maybe where the root is, is different. By outputting it you could find out if its pointing to somewhere else. 1 line of code equals many bugs. So don't write any!!

                        M Offline
                        M Offline
                        Michael Flanakin
                        wrote on last edited by
                        #17

                        The only thing I can assume is that, since I'm using URL rewriting and the physical page is at the root of the website, resolving the URL gives a relative path of Images/Edit.gif instead of /myVirtualDirectory/Images/Edit.gif, which is what I need. Michael Flanakin Web Log

                        I 1 Reply Last reply
                        0
                        • M Michael Flanakin

                          The only thing I can assume is that, since I'm using URL rewriting and the physical page is at the root of the website, resolving the URL gives a relative path of Images/Edit.gif instead of /myVirtualDirectory/Images/Edit.gif, which is what I need. Michael Flanakin Web Log

                          I Offline
                          I Offline
                          Ista
                          wrote on last edited by
                          #18

                          Well I tried. The only thing I can say is that, since rows appear so should the repeater. So it would leave one to think its the path. the "~" will give the root of the web app so more than likely it's the way the virtual folder is defined. But since your using URL rewriting, and this is what I would do. Verify the class of URL writing is actually working with a test app. It seems that the re-writer isnt pointing to the necessary path only when in the repeater. Maybe output the redirected URL inside the repeater so you can see what the path is. Its all about the interpreted path. I wish I could be of more help. This sounds like a hair-puller! Nick 1 line of code equals many bugs. So don't write any!!

                          M 1 Reply Last reply
                          0
                          • I Ista

                            Well I tried. The only thing I can say is that, since rows appear so should the repeater. So it would leave one to think its the path. the "~" will give the root of the web app so more than likely it's the way the virtual folder is defined. But since your using URL rewriting, and this is what I would do. Verify the class of URL writing is actually working with a test app. It seems that the re-writer isnt pointing to the necessary path only when in the repeater. Maybe output the redirected URL inside the repeater so you can see what the path is. Its all about the interpreted path. I wish I could be of more help. This sounds like a hair-puller! Nick 1 line of code equals many bugs. So don't write any!!

                            M Offline
                            M Offline
                            Michael Flanakin
                            wrote on last edited by
                            #19

                            It's definitely odd. I've seen the same code in a DataList and DataGrid and they both work. I'm not sure if I've seen any implementations with a Repeater or not, but it just doesn't seem right for it not to work. Michael Flanakin Web Log

                            I 1 Reply Last reply
                            0
                            • M Michael Flanakin

                              It's definitely odd. I've seen the same code in a DataList and DataGrid and they both work. I'm not sure if I've seen any implementations with a Repeater or not, but it just doesn't seem right for it not to work. Michael Flanakin Web Log

                              I Offline
                              I Offline
                              Ista
                              wrote on last edited by
                              #20

                              It might be something internal inside the repeater and the way it renders. A DataList is just an enhanced repeater so it might save time not to deal with it. Although extending the repeater and stepping through the render might lead to answer the "why" question. Although, it's probably not worth the time and effort in a business setting. Good luck with that. Nick 1 line of code equals many bugs. So don't write any!!

                              M 1 Reply Last reply
                              0
                              • I Ista

                                It might be something internal inside the repeater and the way it renders. A DataList is just an enhanced repeater so it might save time not to deal with it. Although extending the repeater and stepping through the render might lead to answer the "why" question. Although, it's probably not worth the time and effort in a business setting. Good luck with that. Nick 1 line of code equals many bugs. So don't write any!!

                                M Offline
                                M Offline
                                Michael Flanakin
                                wrote on last edited by
                                #21

                                I just decided to hard-code the virtual directory name. Not what I wanted, but it works. Michael Flanakin Web Log

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups