如何从AJAX的HTML编辑器值(非HTML)编辑器、AJAX、HTML

2023-09-10 19:03:06 作者:此生、詠别

请帮我拿到的文本(非HTML /未格式化)从阿贾克斯文本编辑器在asp.net我使用VS 2008。

Please help me to get text (non html/ not formatted) from ajax text editor in asp.net i am using vs 2008.

我使用AjaxControlToolkit.HTMLEditor

i am using AjaxControlToolkit.HTMLEditor

您可以看到同类的: AJAX HTML编辑器

推荐答案

那么,你链接到只在页面上的文件显示, HTML编辑器有一个内容属性,它是HTML文本,而不是纯文本。不过,编辑器本身,在网页上,可以让您查看呈现的HTML,或HTML code(标记)。

Well, the documentation on the page you linked to only shows that the HTMLEditor has a Content property, which is the html text, not the plain text. However, the editor itself, on the page, allows you to view either the rendered html, or the html code (the markup).

编辑器使用了< IFRAME> 包含呈现的HTML。如果你想获得的纯文本(不包括HTML标记),你就必须这样做对客户方。该< IFRAME> 有一个id。你可以使用像jQuery来做到这一点:

The editor uses an <iframe> to contain the rendered html. If you want to get the plain text (no html tags), you'll have to do it on the clientside. The <iframe> has an id. You could use something like jquery to do this:

var plainText = $("#iframeID body").text();
$("#someHiddenField").val(plainText);

只要 someHiddenField &LT; ASP:HiddenField&GT; 控件,它包含的纯文本当您发布的编辑器了。你只需要确保你做出上述分配的在的大功告成编辑HTML编辑器的内容,但是的在的你居然回发。

As long as someHiddenField is an <asp:HiddenField> control, it will contain the plain text of the editor when you post back. You just need to make sure you make the above assignment after you're done editing the HTMLEditor's content, but before you actually post back.

更新

我回答了另一个类似的问题,我的第一个答案可能不是真正得到了&LT的文本; IFRAME&GT; 。试试这个:

I answered another similar question, and my first answer might not actually get the text of the <iframe>. Try this:

var text = $("#iframeID").contents().find("body").text();
 
精彩推荐