Reputation: 5
I have a Label which gets from my database the data "1_1" this is the file name of an image I would like to show relative to the ID.
my image link is
<img src="Images/Dropox/.jpg"/>
with no file name
I would like to know how to add a label that on load will be populated with the string "1_1" and then for that string to go into my SRC link.
I have tried adding the label into the space required but that doesn't work.
my idea would be something along the lines of
<img src="Images/Dropox/<asp:Label ID="ImageSequencea" runat="server">.jpg"/></asp:Label>
or something like that. can anyone help?
thanks!
Upvotes: 0
Views: 2121
Reputation: 778
Try this,
<img src="Images/Dropox/<%#Eval("ReturnEntityName")%>.jpg"/></asp:Label>
Upvotes: 0
Reputation: 56716
Label
corresponds to the <span>
. Which means that when ASP.NET engine finds a Label
on the page, it takes its Text
, wraps into <span>
, and sends to the output. Most likely you are not looking for:
<img src="Images/Dropox/<span>1_1</span>.jpg"/>
If you just need url to be Images/Dropox/1_1.jpg
with 1_1
being inserted at runtime, you can:
Just turn your img
tag into server tag and set its value in code behind:
<img id="DropboxImage" runat="server" />
Use scriplet and call function from code behind
<img src="Images/Dropox/<%= GetImageName() %>.jpg"/>
User asp:Image
and set its ImageUrl
property in code behind:
<asp:Image runat="server" ID="DropboxImage" />
Upvotes: 1