Multi Line in DialogService.Confirm()

Using a method in a @code block is perfectly fine. You can also do that in C# entirely (in a .cs file):

RenderFragment GetDeleteAttachmentMessage(Attachment attachment)
{
    return builder =>
    {
        builder.AddContent(0, "Are you sure you want to delete the following attachment? This action cannot be undone.");
        builder.AddMarkupContent(1, "<br/><br/>");

        builder.OpenElement(2, "strong");
        builder.AddAttribute(3, "style", "color: var(--rz-primary);");
        builder.AddContent(4, attachment.FileName);
        builder.CloseElement();
    };
}

Or in a single method when not using any Blazor components and just HTML content:

using Microsoft.AspNetCore.Components;

RenderFragment GetDeleteAttachmentMessage(Attachment attachment)
{
    return builder =>
    {
        builder.AddMarkupContent(0,
            $"Are you sure you want to delete the following attachment? This action cannot be undone." +
            $"<br/><br/><strong style=\"color: var(--rz-primary);\">{attachment.FileName}</strong>");
    };
}
1 Like