简体   繁体   English

复制/粘贴到textarea时保留html标签

[英]Retain html tags when copy/pasting to textarea

I have a need for the user to select text in another (external) web page, and copy/paste it to a html textarea txaQuote (which has a runat server attribute). 我需要用户在另一个(外部)网页中选择文本,然后将其复制/粘贴到html textarea txaQuote(具有runat服务器属性)。

I then capture the value as: 然后,我将值捕获为:

string quote = txaQuote.Value;

This however captures only the "text" - any html tags (if for example the source has any <a> tags or spans <p></p> tags) aren't preserved. 但是,这仅捕获“文本”-不保留任何html标记(例如,源具有任何<a>标记或跨度<p></p>标记)。 is there any way to do so? 有什么办法吗?

string quote = txaQuote.InnerHtml 

and

string quote = txaQuote.InnerText

don't work, so I'm guessing the html is actually lost in the copy/paste process itself. 不起作用,所以我猜测html实际上在复制/粘贴过程中丢失了。 Is there a way to preserve it? 有没有办法保存它?

So, it seems to me the problem is with the textarea control itself, it's not rich text. 因此,在我看来,问题出在textarea控件本身,而不是富文本。 By using the menulabs rich text box I can preserve the html. 通过使用menulabs富文本框,我可以保留html。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM