Image URL Rendering Incorrectly
-
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; }
The relative URL is returned. My page is
http://localhost/some/page.aspx
and the rendered image path ishttp://localhost/some/Images/Edit.gif
. Michael Flanakin Web Log -
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
-
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!!
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
-
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
-
Could you allow the user to pick the path? 1 line of code equals many bugs. So don't write any!!
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
-
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
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!!
-
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!!
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
'sItemTemplate
. Michael Flanakin Web Log -
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
'sItemTemplate
. Michael Flanakin Web Log -
Thought that was what we were discussing:confused: 1 line of code equals many bugs. So don't write any!!
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 -
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 -
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!!
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 -
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 LogWell 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!!
-
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!!
It's definitely odd. I've seen the same code in a
DataList
andDataGrid
and they both work. I'm not sure if I've seen any implementations with aRepeater
or not, but it just doesn't seem right for it not to work. Michael Flanakin Web Log -
It's definitely odd. I've seen the same code in a
DataList
andDataGrid
and they both work. I'm not sure if I've seen any implementations with aRepeater
or not, but it just doesn't seem right for it not to work. Michael Flanakin Web LogIt 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!!
-
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!!
I just decided to hard-code the virtual directory name. Not what I wanted, but it works. Michael Flanakin Web Log