How to replace text in Blazor RichTextEditor

Answer:

We can change Rich Text Editor text dynamically, with a button click by using the Interpolation concept with the Value property.

<SfRichTextEditor@ref="RteObj"@bind-Value="@value"> 

    </SfRichTextEditor> 

@code { 

  publicstring Message1 { get; set; } = "aaaa"; 

  publicstring Message2 { get; set; } = "bbbbb"; 

 

  publicstringGetRtevalue() 

   { 

   return$"Value is {Message1}<br/>Rich Text Editor<br/> {Message2}"; 

   } 

  privatevoid OnClicked() 

    { 

        Message1 = "ccccc"; 

        Message2 = "ddddd"; 

        this.value = GetRtevalue(); 

        this.StateHasChanged(); 

    } 

   protectedoverridevoid OnInitialized() 

    {         

        this.value = GetRtevalue(); 

    } 

}

Find the sample for replacing text in Blazor RichTextEditor from here.


Loader.
Up arrow icon