Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4044

How to use alert(),confirm() and prompt() function using Blazor?

$
0
0

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.


Viewing all articles
Browse latest Browse all 4044

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>