Live Chat Icon For mobile
Live Chat Icon

If the raw HTML includes a property reference (i.e. @counter), is there any way of sending @counter as a parameter?

Platform: Blazor| Category: General

Raw HTML can be rendered in Blazor by using MarkupString. You can define the property and pass it to a parameter by using MarkupString.

[Index.razor]

@page "/"

<button class='btn btn-primary' @onclick="OnClickButtonEvent">Counter</button>

@((MarkupString)MyMarkup)

@code { 
    private int count = 0;
    public string MyMarkup;

    public void OnClickButtonEvent()
    {
        ++count;
        MyMarkup = "<div>Current count: <span style=\"color:red\"><b>" + @count + "</b></span></div>";
    }
}

Share with

Related FAQs

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

Please submit your question and answer.