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. Image for the cookie policy date
close icon

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

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.


1 Reply

BS Buvana Sathasivam Syncfusion Team 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 + ""; 
        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 + ""; 
        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 
 


Loader.
Live Chat Icon For mobile
Up arrow icon