test
test

Reputation: 23

string output to html formatting problem

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.media.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);

Upvotes: 1

Views: 188

Answers (3)

Cipi
Cipi

Reputation: 11343

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

Upvotes: 0

Sani Huttunen
Sani Huttunen

Reputation: 24385

You shouldn't escape ':

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

Upvotes: 1

Binary Worrier
Binary Worrier

Reputation: 51711

Don't esacpe the single quotes.

i.e \' should be '

Upvotes: 0

Related Questions