Multi Line in DialogService.Confirm()

I want to show confirm message with multi line of text

  • i tried \n
    Envirenement.NewLine but nothings work
if( await DialogService.Confirm("confirm", "Are you sure you want to delete this mesage \n "+ Environment.NewLine +" <br /> - other eneties will removed also") == true){
// delete 
}```

The first parameter (message) supports HTML - you can add <br> to create a new line.

sorry i was wrong in the first message
It's supported only in second paramater Title but not supported in the first parameter Message

@page "/test"
@inject DialogService DialogService

<div class="rz-p-12 rz-text-align-center">
    <RadzenButton Text="Confirm dialog" ButtonStyle="ButtonStyle.Secondary" 
        Click=@(args => DialogService.Confirm("meesage first line <br /> meassage second line ", "Titre 1 <br /> titre 2")) />
</div>

image

Make sure you are using an up-to-date version. Here is what I tested with:

@inject DialogService DialogService

<div class="rz-p-12 rz-text-align-center">
    <RadzenButton Text="Confirm dialog" ButtonStyle="ButtonStyle.Secondary" 
        Click=@(args => DialogService.Confirm("Are you <br> sure?", "MyTitle", new ConfirmOptions() { OkButtonText = "Yes", CancelButtonText = "No" })) />
</div>

Hi,

Iโ€™m currently using Radzen version 6.4.0 (released on March 29, 2025) and Iโ€™ve noticed that the DialogService.Alert() and DialogService.Confirm() methods do not render HTML in the message parameter.

I tried passing a message with <br /> tags to create line breaks, but the tags are shown as plain text instead of being interpreted as HTML.

Is HTML still supported in the message parameter? If not, is there a recommended way to show multi-line messages without building a custom dialog?

Thanks!

1 Like

As for now it doesn't seem to be supported anymore.

Remove markup string by akorchev ยท Pull Request #2066 ยท radzenhq/radzen-blazor

The line responsible adding the text was changed from:

b.AddContent(i++, (MarkupString)message);

to:

b.AddContent(i++, message);

This change treats the message as plain text.

As the DialogService.Confirm() is virtual you could provide your own implementation restoring the old behavior, or simply add an extension method, which takes a MarkupString instead of string. A more advanced solution would be to implement your own dialog (incl. button handling) and open it with DialogService.OpenAsync<MyDialog>().

Indeed MarkupString support has been globally disabled. We will add new RenderFragment option that would allow using arbitrary markup.

Did anyone figure out how to show multiline text now that MarkupString is globally disabled?"

Using markup in the confirm dialog is demonstrated in the demo:

 <RadzenButton Text="Confirm dialog with markup" ButtonStyle="ButtonStyle.Secondary"
        Click=@(args => DialogService.Confirm(GetMessage(), "MyTitle", new ConfirmOptions() { OkButtonText = "Yes", CancelButtonText = "No" })) />


@code{
    RenderFragment GetMessage()
    {
        return __builder =>
        {
            <text>
                Are <b>you</b> sure?
            </text>
        };
    }
}

And here is how to do it without an explicit method for the content:

    <RadzenButton Text="Confirm dialog with markup" ButtonStyle="ButtonStyle.Secondary"
        Click=@ShowConfirmDialog />
</div>

@code{

    async Task ShowConfirmDialog()
    {
       await DialogService.Confirm(@<text>
          Are you <br /> sure?
        </text>, "MyTitle", new ConfirmOptions() { OkButtonText = "Yes", CancelButtonText = "No" });
    }
1 Like

In the latest version, you can use Markup as explained by Mr. Korchev. However, if you're using an older version where the issue persists even with Markup, you can work around it by opening your own custom dialog using
dialogService.OpenAsync<YourOwnComponent>()
and return a bool on close

I got it working with the solution from korchev. Thank you very much.