Can you stop a Radzen Dialog from closing

I use a dialog to display an edit screen and allow users to update values on that screen. However, if the user clicks the small 'x' on the right hand side of the dialog and there are edits made, I want to prevent the form from closing?

I hooked up the OnClose event of the DIalogService instance in the edit screen and can detect when the dialog is closing but, I want to prevent it closing if edits have been made (I set a boolean flag if any edits have been made on the form)
Here's my method where I detect that the edit form is closing but don't know what to put in-between the if block.

private async void Close(dynamic result)
{
    if (IsDirty)
    {
        //DON'T CLOSE THIS DIALOG !                
    }
}

Is this possible?

At the moment you cannot prevent the Radzen Dialog from closing.

As a workaround, you can hide the button from the dialogs using the CSS.

HI
I have not been able to change anything on the Radzen controls using CSS. I'm not sure even where to find the Radzen class names. I tried out a few examples from this forum by typing in the CSS class and tried changing the colour of something but css doesn't seem to affect any of the Radzen controls :frowning:

@stealthworks you can use your browser's developer tools to inspect the CSS. The Radzen Blazor components are style entirely from CSS so of course they get affected by it.

I hide the Title, which also hides the default close button.
new DialogOptions { ShowTitle = false }

Then create my own title and close button and handle it with that.

<div class="row" style="width: 98%; margin-top: -20px; margin-bottom: 0;margin-left: 1%"> <div class="flex-column" style="width: 80%; text-align: left; vertical-align: middle"> <h6 style="margin: 0">@_subTitle</h6> </div> <div class="flex-column" style="width: 18%; text-align: right; vertical-align: middle"> <button class="fas fa-times" style="font-size: 1em; margin: 0" title="Close this Editor" @onclick="@TryClose"></button> </div> </div>

1 Like