1

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

3 Answers 3

1

You shouldn't escape ':

string feedImage ="http://im.media.ft.com/m/img/rss/RSS_Default_Image.gif"
rssImageStyle = "style=\"background-image:url('" + feedImage + "')\"";
Sign up to request clarification or add additional context in comments.

Comments

0

Don't esacpe the single quotes.

i.e \' should be '

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.