NotificationService formatting

I'm confused with the formatting of the NotificationService or RenderFragment DetailContent.

var message = "User principal name is required<br />Password is required<br />Job title is required<br />Department is required<br />Employee identifier is required";
NotificationService.Notify(new NotificationMessage
{
    Severity = NotificationSeverity.Error,
    Duration = 30000,
    SummaryContent = o =>@<RadzenText TextStyle="TextStyle.H6">Couldn't save new user</RadzenText>,
    DetailContent = o =>@<RadzenText Style="word-break:break-word" Text="@message"></RadzenText>,
    Style = "word-break:break-word"
});

leads to

and

NotificationService.Notify(new NotificationMessage
{
    Severity = NotificationSeverity.Error,
    Duration = 30000,
    SummaryContent = o =>@<RadzenText TextStyle="TextStyle.H6">Couldn't save new user</RadzenText>,
    DetailContent = o =>@<RadzenText Style="word-break:break-word">
        User principal name is required<br />Password is required<br />Job title is required<br />Department is required<br />Employee identifier is required
    </RadzenText>,
    Style = "word-break:break-word"
});

is correct but static and therefore not usable

How can I build a dynamic and correctly formatted string?

Blazor encodes HTML by default. You need to use MarkupString if you want to bypass that:

<RadzenText Style="word-break:break-word">@((MarkupString)message)</RadzenText>
1 Like