开发者

string output to html formatting problem

开发者 https://www.devze.com 2022-12-17 23:45 出处:网络
I have the following string variables: string feedImage =\"http://im.media.ft.com/m/img/rss/RSS_Default_Image.gif\"

I have the following string variables:

 string feedImage ="http://im.media.ft.com/m/img/rss/RSS_Default_Image.gif"

rssImageStyle = "style=\"background-image:url(\'" + feedImage + "\')\"";    

I want it to output the following html

background-image: url('http://im.medi开发者_Go百科a.ft.com/m/img/rss/RSS_Default_Image.gif');

But I get

background-image: url(http://im.media.ft.com/m/img/rss/RSS_Default_Image.gif);


You shouldn't escape ':

string feedImage ="http://im.media.ft.com/m/img/rss/RSS_Default_Image.gif"
rssImageStyle = "style=\"background-image:url('" + feedImage + "')\"";


Don't esacpe the single quotes.

i.e \' should be '


You escaped ' and there is no need to do that. Try this: rssImageStyle = "style=\"background-image:url('" + feedImage + "')\"";

0

精彩评论

暂无评论...
验证码 换一张
取 消