DialogService confirm busy indicator

Hi,

I have successfully implemented a pop-up dialog to confirm a user's action by using DialogService.Confirm() flow. But now I want to implement a busy indicator on the button and disable it while waiting for the call to finish.

I saw this in the Radzen examples source code which would work well for me:

async Task ShowInlineDialog()
    {
     var result = await DialogService.OpenAsync("Simple Dialog", ds =>
        @<div>
            <p class="mb-4">Confirm Order ID <b>@orderID</b>?</p>
            <div class="row">
                <div class="col">
                    <RadzenButton Text="Ok" Click="() => ds.Close(true)" Class="mr-1" Style="width: 80px;" />
                    <RadzenButton Text="Cancel" Click="() => ds.Close(false)" ButtonStyle="ButtonStyle.Secondary" Class="mr-1" />
                    <RadzenButton Text="Refresh" Click="(() => { orderID = 10249; ds.Refresh(); })" ButtonStyle="ButtonStyle.Light"  Class="mr-1 float-right" />
                    
                </div>
            </div>
        </div>);
    
      console.Log($"Dialog result: {result}");
    }

However when I copy that code into my solution it throws a compilation error on the markup code for the RenderFragment parameter

Error CS1662 Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type

My apologies if this isn't related to Radzen, but I'm hoping maybe someone could tell me why. I'm targeting .NET 6.0 (the same as the Radzen project).

You don’t have this in your app most probably.

1 Like

Oh wow that's embarrassing, this was it. Thanks so much.

I got the modal working and tried applying a busy indicator setting the IsBusy property on the Ok button, which I've done successfully with other buttons on the page, but I can't seem to get it to work in the dialogue.

Here is my method:

protected async Task RefundButtonClick()
    {
        var shouldProcess = await dialogService.OpenAsync("Issue Refund", ds =>
         @<div>
             <p class="mb-4">Issue refund for <b>$@refundAmount</b>?</p>
             <div class="row">
                 <div class="col">
                <RadzenButton Text="Ok" Click="() => ds.Close(true)" BusyText="Processing ..." IsBusy=@busyRefundModal Class="mr-1" Style="width: 80px;" />
                     <RadzenButton Text="Cancel" Click="() => ds.Close(false)" ButtonStyle="ButtonStyle.Secondary" Class="mr-1" />

                 </div>
             </div>
        </div>);

        if (shouldProcess)
        {
            busyRefundModal = true;

            ProcessRefund();

            busyRefundModal = false;
        }
     
    }