tags:

views:

34

answers:

1

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

i am using AjaxControlToolkit.HTMLEditor

you can see same kind of at : ajax HtmlEditor

+1  A: 

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).

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);

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.

UPDATE

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();
Samuel Meacham