Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

Problem with RadRichTextBox with HTMLFormatProvider

$
0
0

Hi Telerik Team,

  I am using Telerik RadRichTextBox. I am trying to get the text from Clipboard (when user copy pastes onto Telerik RadRichTextBox) and then remove the images if any in the text and then using HtmlFormatProvider -> Import(); method to get the data .

  But this returns a special character at the start of the text. Please see attached text.

Could you please advice why this is happening and how I can get html text without the special character ??????

Here is the sample code : 

string textToInsert = Clipboard.GetText(TextDataFormat.Html);

//remove the images
while (true)
{
int startIndexOfImage = textToInsert.IndexOf("<img");
if (startIndexOfImage <= 0)
{
break;
}

int endIndexOfImage = textToInsert.IndexOf(">", startIndexOfImage);
textToInsert = textToInsert.Remove(startIndexOfImage, (endIndexOfImage - startIndexOfImage)+1);
}

MessageRadRichTextBox.Document = ImportHtmlAsRadDocument(textToInsert);

 

 

public static RadDocument ImportHtmlAsRadDocument(string content)
{
if (content != null)
{
HtmlFormatProvider provider = new HtmlFormatProvider();
return provider.Import(content);
}
return new RadDocument();
}

 

 


Viewing all articles
Browse latest Browse all 94857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>