0

I want to bind html from c#. I tried with the below code it's working

HtmlTextWriter.write("<a onclick=\"window.open('', '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes').document.write('<p>test<P>')\">);

then I try to add img tag in it then html is breaking

eg:

 HtmlTextWriter.write("<a onclick=\"window.open('', '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes').document.write('<img src=\"path\">')\">);

please help to solve this.

user8278302
  • 13
  • 1
  • 3

2 Answers2

1

Use &quot; instead of actual quote character ".
See this answer.

string html = "<a onclick=\"window.open('', '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes').document.write('<img src=&quot;path&quot;>')\">";
HtmlTextWriter.Write(html);

See this html in jsfiddle.

stomtech
  • 454
  • 4
  • 10
  • I passing base64 image in ,but it's not showing full image in new opening window.Base64 content showing correctly in img src,while click on link to open new window it shows half of image.please help to resolve – user8278302 Jul 10 '17 at 10:29
  • @user8278302 : Can you post the base64 image string? – stomtech Jul 11 '17 at 17:58
0

You can use the @" your string here " in C#. But for every " you have to use ""

HtmlTextWriter.write(@"<a onclick=""window.open('', '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes').document.write('<img src=""path"">')"">");
Yousuf Hossain
  • 172
  • 1
  • 12