How do I get/render the raw HTML from Blazor components?

Platform: Blazor| Category: Components

In Blazor, you can render raw HTML from a component using the MarkupString type. The MarkupString type allows you to render HTML content directly without being sanitized or escaped by the framework.  

Here’s how you can use MarkupString to render raw HTML in a Blazor component: 

@((MarkupString)RawString)
 
@code {
    public string RawString = "<span style='color:red'>Blazor is awesome</span>";
}

View Sample in GitHub

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.