kirank
September 20, 2025, 6:51pm
1
I copied this from your demo but I'm getting errors.
void ShowNotificationWithCustomContent()
{
NotificationService.Notify(new NotificationMessage
{
Severity = NotificationSeverity.Warning,
Duration = 40000,
SummaryContent = ns =>@<RadzenText TextStyle = "TextStyle.H6" > Custom summary: < br /> @DateTime.Now </RadzenText >,
DetailContent = ns => @<RadzenButton Text = "Clear" Click = "@(args => ns.Messages.Clear())" />
});
}
If I use Summary & Detail, it's fine. I tried html inside Detail but that doesn't work.
Not sure what I'm doing wrong.
enchev
September 21, 2025, 5:32am
2
Such code can be used in razor file only - you cannot use it in plain code cs file.
kirank
September 21, 2025, 10:12am
3
Thank you for your reply.
What's the equivalent of this in code behind ie. how do I specify DetailContent in codebehind for NotificationMessage?
Does Detail in NotificationMessage not support any html?
enchev
September 21, 2025, 10:52am
4
Injecting HTML in Blazor can be vulnerable and that’s why RenderFragment should be used. Check official Microsoft documentation on this topic:
Keep in mind that there is no problem to have code in both razor @code blocks and the cs file since they are partial classes.
kirank
September 21, 2025, 7:53pm
5
Thank you.
I understand why Detail doesn't allow html. All I want to achieve is a multiline notification message. What's the easiest way to achieve this without writing the same @code wherever it's used
NotificationService.Notify(new NotificationMessage() { Severity = NotificationSeverity.Error, Summary = $"Error", Detail = $"Paragraph 1. Paragraph 2" });
korchev
September 21, 2025, 9:06pm
6
You can check my reply here: Multi Line in DialogService.Confirm() - #14 by korchev
Here is something that will work in a regular C# file:
NotificationService.Notify(new NotificationMessage
{
Severity = NotificationSeverity.Warning,
Duration = 40000,
SummaryContent = ns => builder => builder.AddMarkupContent(0, "<strong>Summary</strong>"),
DetailContent = ns => builder => builder.AddMarkupContent(0, "Paragraph 1 <br />Paragraph 2")
});
kirank
September 21, 2025, 11:52pm
7
Thank you @korchev . I'll give that a try