asp:image not visible when dynamic

  • Thread starter Thread starter Deere
  • Start date Start date
D

Deere

When I try to take a database field and change it with a function and
return it...it will not display the image. The "Imageurl" does not
convert to "src=" but stays as ImageUrl.

id=Image2 will display ok ..and shows in view source as .......

<img id="gvwExample_ctl07_Image2"
src=".\images\toys\1_16\thumb\t_15511.jpg" style="border-width:0px;" />


id=Image3 will not display image and shows in view source as.......

<asp:Image id="Image3" ImageUrl=".\images\toys\1_16\thumb\t_15511.jpg"
runat="server" />

What am I doing wrong.....thanks



the "imageref": field below starts out as
".\images\toys\1_16\15511.jpg"
the function returns ".\images\toys\1_16\thumb\t_15511.jpg"

Code:

<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image id="Image2"
ImageUrl=".\images\toys\1_16\thumb\t_15511.jpg" runat="server" />
<asp:Image id="Image3"
ImageUrl="<%#testthis(Eval("imageref"))%>" runat="server" />
</ItemTemplate>
</asp:TemplateField>
 
Your slashes are in the wrong direction. They should be / instead of \

It could be that IE is able to translate it around, but ASP.Net could be
getting stuck as it will try to verify the path.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
Thanks for your response Mark but my test show the image will not
dispIay if the path slashes are / ... If you look at the the literal or
static path of Image2 which is / it will display. Its just the dynamic
return of the Image3 path that won't, even though it returns the same
path as the test static path of Image2

Any other thoughts would be appreciated.
 
Mark sorry I was wrong, the image will display no matter which way
the slashes are. I overwrote a letter when changing the slashes
eariler.
 
I got it to work by switching the double quotes to single on this
ImageUrl="<%#testthis(Eval("imageref"))%>" to
ImageUrl='<%#testthis(Eval("imageref"))%>'
not sure why as I had single quotes originally...sheesh programming
 
Back
Top