Quotes/Double Quotes in Image Control

C

Chris White

I'm trying to put a dynamic image inside a Data Repeater.

<asp:Repeater id="repModels" runat="server">
<ItemTemplate>
<asp:Image id="Image1" runat="server" ImageUrl="images/cars/small/<%#
Databinder.Eval(Container.DataItem, "Picture") %>">
</asp:Image>
</ItemTemplate>
</asp:Repeater>

This was giving me Parser Error Message: The server tag is not well formed
After doing some searching, I replaced the outer double quotes with single
quotes

<asp:Repeater id="repModels" runat="server">
<ItemTemplate>
<asp:Image id="Image1" runat="server" ImageUrl='images/cars/small/<%#
Databinder.Eval(Container.DataItem, "Picture") %>'>
</asp:Image>
</ItemTemplate>
</asp:Repeater>

This doesn't work, the Databinder.Eval does not even get parsed.
And why does the above Not work and the code below does?

<asp:Repeater id="repModels" runat="server">
<ItemTemplate>
<asp:HyperLink id="Hyperlink1" NavigateUrl='' Text='<%#
Databinder.Eval(Container.DataItem, "Picture") %>' Runat="server">
</asp:HyperLink>
</ItemTemplate>
</asp:Repeater>

And finally, is there any real benefit using an asp:Image tag instead of an
img tag?
 
H

Hermit Dave

try this
<asp:Repeater id="repModels" runat="server">
<ItemTemplate>
<asp:Image id="Image1" runat="server" ImageUrl='<%#
"images/cars/small/ " +
Databinder.Eval(Container.DataItem, "Picture") %>'>
</asp:Image>
</ItemTemplate>
</asp:Repeater>

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top