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

How can I display a window alert in Blazor within my try-catch block with the error message? [duplicate]

$
0
0

I have created an application in Blazor with C#, JavaScript, HTML and CSS and would like to receive a pop-up with the message from the try-catch block in case of an error, like this:

try{  // Here is my code}catch (Exception ex){  // alert(ex.Message); something like that  // Here I want the window alert}

Does anyone have an idea how I can do this? It doesn't necessarily have to be a window alert, but I want a notification that pops up when entering the catch block with the error message.

i try this:

try{  // Here is my code}catch (Exception ex){throw new InvalidOperationException(ex.Message);alert(ex.Message);}

the first one didn't work and the second one comes to error --> Error CS0103 The name 'alert' does not exist in the current context


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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