Skip to main content

DxPopupBase.ShowAsync(CancellationToken) Method

Asynchronously shows the Popup.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public Task<bool> ShowAsync(
    CancellationToken token = default(CancellationToken)
)

Optional Parameters

Name Type Default Description
token CancellationToken null

An object that propagates a cancellation notification.

Returns

Type Description
Task<Boolean>

An asynchronous operation that shows the Popup.

Remarks

Call the ShowAsync and CloseAsync methods to show and close the Popup asynchronously. Make sure the component has been initialized before you call the ShowAsync method. Use the IsInitialized property to check the initialization state.

@inject IJSRuntime JsRuntime

<DxButton RenderStyle="ButtonRenderStyle.Primary" Text="Show" Click="ShowClick" />

<DxPopup @bind-Visible="@PopupVisible"
         HeaderText="Header"
         BodyText="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sit amet metus vel
             nisi blandit tincidunt vel efficitur purus. Nunc nec turpis tempus, accumsan orci auctor,
             imperdiet mauris. Fusce id purus magna."
         ShowFooter="true"
         @ref="Popup">
    <FooterContentTemplate>
        <DxButton RenderStyle="ButtonRenderStyle.Primary" Text="Close" Click="CloseClick" />
    </FooterContentTemplate>
</DxPopup>

@code {
    DxPopup Popup;
    bool PopupVisible { get; set; } = false;

    async Task ShowClick(MouseEventArgs args)
    {
        if (Popup.IsInitialized)
            await Popup.ShowAsync();
        else
            await JsRuntime.InvokeVoidAsync("alert", "The component has not been initialized yet. Please try later.");
    }

    async Task CloseClick(MouseEventArgs args)
    {
        await Popup.CloseAsync();
    }
}

You can handle the following events related to these methods:

  • Showing - Fires before the Popup is displayed and allows you to cancel this action.
  • Shown - Fires after the Popup is displayed.
  • Closing - Fires before the Popup is closed and allows you to cancel this action.
  • Closed - Fires after the Popup is closed.

To show and close the Popup synchronously, implement two-way binding for the Visible property.

See Also