Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to correctly paste HTML into C# code with Visual Studio or Resharper (or any other tool!)?

Is there any way to make a "safe" paste into Visual Studio (C#) of HTML code? If I try to paste something like

<div class="user-info"><div class="user-action-time">answered <span title="2010-09-16 02:23:16Z" class="relativetime">21 mins ago</span>

into my code, C# will cry. Using the @ operator doesn't help us, either.

Is it possible to make a special paste in Visual Studio (2010) or Resharper?

Thanks

like image 682
devoured elysium Avatar asked Sep 16 '10 03:09

devoured elysium


2 Answers

You can use SmartPaster Extention.

After install Right click -> Paste As... -> Paste as @String

Download links

  • SmartPaster for Visual Studio 2022
  • SmartPaster for Visual Studio 2019 and earlier
like image 154
Eric Liprandi Avatar answered Oct 18 '22 01:10

Eric Liprandi


Use @, select pasted text and replace " with "" in the selection. That's what I do when I paste text containing quotes.

like image 28
Alex Paven Avatar answered Oct 18 '22 01:10

Alex Paven