Confirmation message using Blazorise component


Step 1: Install the Blazorise nuget package and do the required configuration

Step 2: Create the Hello.razor component and write the code like this

@page "/hello"

<Button Color="Color.Primary" Clicked="@ShowInfoMessage">Say hi!</Button> <br />
<Button Color="Color.Danger" Clicked="@ShowConfirmMessage">Confirm</Button>


@code{
    [Inject] IMessageService MessageService { get; set; }

    Task ShowInfoMessage()
    {
        return MessageService.Info( "This is a simple info message!", "Hello" );
    }

    async Task ShowConfirmMessage()
    {
        if ( await MessageService.Confirm( "Are you sure do you want to delete ?", "Confirmation" ) )
        {
            Console.WriteLine( "OK Clicked" );
        }
        else
        {
            Console.WriteLine( "Cancel Clicked" );
        }
    }
}

Step 3: Go to App.razor page and inject component like this

Now run the application, you will see the confirmation message like above screen shoot.