Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
i have requirement to bind value in repeater itemtemplate without any single or double quote...currently for reference i add html code

<div data-thumb=images/banner2.jpg data-src="images/banner2.jpg">


above code in my repeater looks like..

<div data-thumb="<%#"~/banner/" +Eval("banner_image") %>" data-src='<%#"~/banner/" +Eval("banner_image") %>' data-title="dfdsfds">


so i want to bind data-thumb value without single or double quote because u can see the html data-thumb has value without any quote....
Posted

1 solution

You can do the concatenation through a C# method and return it to display .

Try like

C#
<%# GetImageWithPath(Eval("banner_image"))%>  

And the method

C#
public string GetImageWithPath(object bannerImage)
  {
      return "bannerpath"+Convert.ToString(bannerImage);//modify path accordingly
  }
 
Share this answer
 
v2
Comments
Sumit_Pathak 24-Jan-14 5:42am    
thanks for solution..but i didn't get right answer..actually when i add single quote with this then banners are not working in ie8..and it still not working..
JoCodes 24-Jan-14 5:49am    
use a string.format or may b escape sequences for quotes or even @ character before a string. if the paths are correct it will work.
Sumit_Pathak 24-Jan-14 6:14am    
from that code thumbnail images are shows but main banners are not visible..i had checked console but there is no error or warning related that...and also i m getting this warning...Attribute values must be enclosed in quotation marks.
JoCodes 24-Jan-14 6:22am    
try with @"stringpathwithquotes"
JoCodes 24-Jan-14 6:24am    
Refer http://stackoverflow.com/questions/1928909/in-c-can-i-escape-a-double-quote-in-a-verbatim-string-literal

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900