locked
HTML Tags in Blazor variables RRS feed

  • Question

  • User1640282781 posted

    In my .razor file, this piece shows up correctly:

    <td><b>My</b> house</td>  (meaning the "My" shows in bold text)

    but this:

    string myhouse = "<b>My</b> house";

    <td>@myhouse</td>

    shows up as <b>My</b> house

    I just got started with Blazor, but I could not find this discussed anywhere.

    Many thanks,

    Rene

    Saturday, April 11, 2020 9:18 PM

All replies

  • User1760891592 posted
    Check this MarkupString

    https://docs.microsoft.com/en-us/aspnet/core/blazor/components?view=aspnetcore-3.1#raw-html
    Sunday, April 12, 2020 5:26 AM
  • User-857013053 posted

    You can try this

    @((MarkupString)myhouse)

    @functions {

    string myhouse ="<b>My</b>house";

    }

    Friday, May 1, 2020 6:34 AM