1

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/";

}
Vladimir Potapov
  • 2,347
  • 7
  • 44
  • 71

2 Answers2

1
<img src='<%# new Uri(new Uri(Path), Eval("Image")).AbsoluteUri %>' />
rtpHarry
  • 13,019
  • 4
  • 43
  • 64
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
0

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

Community
  • 1
  • 1
Believe2014
  • 3,894
  • 2
  • 26
  • 46