Reputation: 2437
I built items with image the src
of image combine with path than in server and image name that in db .I need to combine them but in the HTML .
This is my code
<asp:ListView ID="ul_LeftMenu" runat="server" ClientIDMode="Static">
<ItemTemplate >
<li class="li-LeftMenu">
<img src="<%=Path %><%# Eval("Image") %>" /><a href="../<%# Eval("Url") %>"><%#Eval("Name") %></a></li>
</ItemTemplate>
</asp:ListView>
<%=Path %>
from server Side
<%# Eval("Image") %>
from database
How to make some think like this
<img src=" Url.Combine(<%=Path %> ,<%# Eval("Image") %>)"/>
Server code
public string Path { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
Path = "/Master/Images/";
}
Upvotes: 1
Views: 2527
Reputation: 3964
If you have a base class for your controller, you could copy and paste the code in this answer to be part of your base class.
Otherwise, you can copy the entire Uri class from Codeplex to your project. That will extend the System.Uri
with a new Combine()
function
Upvotes: 0
Reputation: 1039000
<img src='<%# new Uri(new Uri(Path), Eval("Image")).AbsoluteUri %>' />
Upvotes: 1