Live Chat Icon For mobile
Live Chat Icon

How do I render raw HTML in Blazor?

Platform: Blazor| Category: General

Raw HTML can be rendered in Blazor by using the MarkupString. You can set the raw HTML as a string to any parameter and cast it in a markup string.

@page "/"

@((MarkupString)myMarkup)

@code {
              string myMarkup = "<p class='markup'>This is a <em>markup string</em>.</p>    <button class='btn btn-primary'>Button</button>";
   }

Reference link: https://stackoverflow.com/questions/50604366/is-there-an-equivalent-to-html-raw-in-blazor?answertab=active#tab-top

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

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

Please submit your question and answer.