Class BeforeCloseEventArgs
Provides arguments for the OnClose event, which is triggered before the dialog closes.
Inherited Members
Namespace: Syncfusion.Blazor.Popups
Assembly: Syncfusion.Blazor.dll
Syntax
public class BeforeCloseEventArgs
Remarks
This event can be used to perform actions or validations before the dialog is closed. The closing process can be canceled by setting the Cancel property to true.
Constructors
BeforeCloseEventArgs()
Declaration
public BeforeCloseEventArgs()
Properties
Cancel
Gets or sets a value indicating whether the closing of the dialog should be canceled.
Declaration
public bool Cancel { get; set; }
Property Value
| Type | Description |
|---|---|
| bool | A |
Remarks
Set this property to true to prevent the dialog from closing.
ClosedBy
Gets a value indicating how the dialog was requested to be closed.
Declaration
public string ClosedBy { get; set; }
Property Value
| Type | Description |
|---|---|
| string | A |
Remarks
This property helps determine whether the dialog was closed via the close icon, the Escape key, or another user-defined action.
Event
Gets the underlying event arguments that triggered the close action.
Declaration
public EventArgs Event { get; set; }
Property Value
| Type | Description |
|---|---|
| EventArgs | An EventArgs object. |
Remarks
This can be a MouseEventArgs for a click or a KeyboardEventArgs for a key press.
IsInteracted
Gets a value indicating whether the dialog was closed through user interaction.
Declaration
public bool IsInteracted { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Remarks
This allows distinguishing between programmatic closing and user-initiated actions.
PreventFocus
Gets or sets a value indicating whether to prevent restoring focus to the previously active element after the SfDialog closes.
Declaration
public bool PreventFocus { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Remarks
When set to true, the SfDialog will not restore focus to the element that was active before the dialog opened,
allowing for custom focus management. This is useful in multi-dialog workflows, form continuity scenarios, or when integrating
with assistive technologies that handle focus independently.
When set to false (default), the dialog automatically restores focus to the previously active element.
Examples
<SfDialog @bind-Visible="@IsVisible">
<DialogEvents OnClose="OnDialogClose"></DialogEvents>
<DialogTemplates>
<Content>Dialog content</Content>
</DialogTemplates>
<DialogButtons>
<DialogButton Content="Close" OnClick="@OnButtonClick" />
</DialogButtons>
</SfDialog>
@code {
private bool IsVisible { get; set; } = true;
/// private void OnDialogClose(BeforeCloseEventArgs args)
{
args.PreventFocus = true; // Prevent focus restoration
}
private void OnButtonClick()
{
IsVisible = false;
}
}