We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Unable to get text & HTML together using GetText() and GetHtml()

Thread ID:

Created:

Updated:

Platform:

Replies:

146236 Jul 27,2019 04:18 AM UTC Jul 29,2019 09:09 AM UTC Blazor 1
loading
Tags: Rich Text Editor
Dominick Marciano
Asked On July 27, 2019 04:18 AM UTC

I am using a RTE for content creation.  When the user submits the data I am trying to get the HTML as well as a text only version of the content entered by the user using the GetText() and GetHtml() methods.  However, if I call these after one another, the second call returns an empty string.  For example, if I have:

var text = await ejsArticleContent.GetText();
var html = await ejsArticleContent.GetHtml();

Then text will have the plain text of what was entered but html with be an empty string.  If I reverse the calls like so:

var html = await ejsArticleContent.GetHtml();
var text = await ejsArticleContent.GetText();

Then html will have the HTML version of the content entered but text will be an empty string.


Buvana Sathasivam [Syncfusion]
Replied On July 29, 2019 09:09 AM UTC

Hi Dominick, 

Greetings from Syncfusion support.  
 
We have tried to replicate the issue with the given code and the following ways, but we were not able to reproduce the issue with these methods “GetText and GetHtmlat our end. 
  • Async modifier usage in method handler
  • Access RTE method without the instance
 
We have prepared sample for your reference, get it from below link 

Sample code block: 

 
<button class="e-btn e-outline" @onclick="@getTextHtml">Text After Html</button> 
<button class="e-btn e-outline" @onclick="@getHtmlText">Html After Text</button> // Button click to call the GetText and GetHtml method 
 
<br><br> 
 
<EjsRichTextEditor @ref="rte"> 
    <p>Sample Text</p> 
</EjsRichTextEditor> 
 
<br> 
 
<div> 
    <b>Text After Html result</b> 
    <br> 
    <pre>@output1</pre>    // Used to print the output1 variable result in DOM 
    <br> 
    <b>Html After Text result</b> 
    <br> 
    <pre>@output2</pre>    // Used to print the output2 variable result in DOM 
</div> 
 
@code{ 
    EjsRichTextEditor rte; 
 
    private string output1 = ""; 
    private string output2 = ""; 
 
    private async void getTextHtml() 
    { 
        var text = await this.rte.GetText(); 
        var html = await this.rte.GetHtml(); 
 
        this.output1 = "getText method Result: " + text + "\n\n"; 
        this.output1 = this.output1 + "getHtml method Result: " + html; 
        StateHasChanged(); // Used for append the current change of output1 variable into DOM 
    } 
 
    private async void getHtmlText() 
    { 
        var html = await this.rte.GetHtml(); 
        var text = await this.rte.GetText(); 
         
        this.output2 = "getHtml method Result: " + html + "\n\n"; 
        this.output2 = this.output2 + "getText method Result: " + text; 
        StateHasChanged();// Used for append the current change of output2 variable into DOM 
    } 
} 
 
 
Still if you face same issue, please share your code or modify the above sample to reproduce your issue and revert it to us. This will help us provide a solution.  
 
Regards, 
Buvana S 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon