Ravi
Ravi

Reputation: 307

passing html string to stringbuilder does not work

I am writing html tags in a an html file by following code in C#:

StringBuilder sbMarquee = new StringBuilder();
sbMarquee.Append("<a href= #  onclick = showimage('Images\\\\Code00005_0001.jpg')>").Append("<img src=Images\\\\thumbnails\\\\Code00005_0001.jpg></img>").Append("</a>");
_hdCaseMarquee.InnerHtml = sbMarquee.ToString();

But, I get following HTML output:

<a href="#" onclick="showimage('Images\\Code00005_0001.jpg')"><img src="Images\\thumbnails\\Code00005_0001.jpg"></a></marquee>

Following tag from the string is completely ignored:

</img>

Please Help

Upvotes: 0

Views: 816

Answers (1)

spender
spender

Reputation: 120390

I assume that you're looking at the HTML from the browser, in which case there's a strong likelihood that the closing tag of the img gets gobbled by the HTML parser for the following reason:

img

Tag omission Must have a start tag and must not have an end tag.

Upvotes: 6

Related Questions