I'm learning the Blazor technology. I started a default increment project in VS 2019 and I have modified the code for Decrement with confirm()
and alert
but it does not work.
@page "/counter"<h1>Counter</h1><p>Current count: @currentCount</p><button class="btn btn-primary" @onclick="IncrementCount">Increment</button><button class="btn btn-primary btn-danger" onclick="if (confirm('Are you sure to Decrement')) { @DecrementCount() }">Decrement</button>@code { private int currentCount = 0; private void IncrementCount() { currentCount++; } private void DecrementCount() { currentCount--; // alert('Operation Successfully executed') }}
In my code snippet confirm()
function works perfectly but I want to call a Decrement function is not working build failed.And I would like to add a success message in my function.Please provide any option instead of using confirm()
,alert()
functions.