> For the complete documentation index, see [llms.txt](https://docs.gapvelocity.ai/webmap-for-blazor-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gapvelocity.ai/webmap-for-blazor-documentation/blazor-ai-migrator/research-for-blazor/issue-with-using-messagebox.show-in-blazor.md).

# Issue with using "MessageBox.Show" in Blazor

## Issue to be solve

In Winforms you can have a constructor for a Form, and call a MessageBox.Show or a method that calls the MessageBox.Show

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfGc8zrX1p7Wdtquq7DajDF_JWFodt0rTwnF1Qsi6zciZAz6N342CnS1kku4LSRYujPxjtzmKl46LB7bScTg31OkQeEmgRdTALf6by1AGnk9A6HHAc1_9OTYqR37g6qoKFG9gWMpg?key=UMdHdUL4IHw5n8uioKW5hhK4" alt=""><figcaption></figcaption></figure>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeNDOyvmrvB3O1p9h6fYLw2E8FpWdnHMc1X42jY2CzNV-Wl1RM9vTtHktM74uhXkm5VokLHX24Tfy2G_cjyqHBhvCSHkRHhmqEVcr3jv2YUbKI_4KMWCiPC2_OJORU6zBH1xb56jg?key=UMdHdUL4IHw5n8uioKW5hhK4" alt=""><figcaption></figcaption></figure>

In Blazor, we need to wait for the MessageBox response(in most cases) to continue execution. Why most cases?&#x20;

As an example, if we have a MessageBox.Show(“Message”), this is just an Expression Statement. We don’t need to wait for a response because it is just a notification, this means that the application does not need to wait for a response.

## Proposed solution

What if we just show a notification in a web oriented way? Well, we can use the [TelerikNotification](https://demos.telerik.com/blazor-ui/notification/overview?_gl=1*1j69o9y*_gcl_au*NjQ0NzU2MTEuMTc0NDY1MzU0Mg..*_ga*NTkzMjU2NDgyLjE3MzY3OTA1MDQ.*_ga_9JSNBCSF54*MTc0NDY1MzU0Mi44LjAuMTc0NDY1MzU0NC41OC4wLjA) component.

This allow us to just show the notification without having to wait for the result or response.

So to achieve this, it is needed to have an event or service to notify TelerikNotification to show and use the correct message. And, by migration, we need to replace the MessageBox.Show by a different statement. The approach is to have a TelerikNotification component in the WMApp component, and this control will be listening for a subscription to show the message

### Blazor Desktop Compativility Platform

<div data-full-width="false"><figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXd4wH1lulJ7nStQQ6hTIQDDR1BSevrYH4xMPp0PVBd7z3ZMyVdntgEFYMLlq526CascVMcLVEyjEsGmLrCZGw7UC2Jd8-aoojcWaNu9trtoqK7KtL4BuY19fcs7HbjY5KORZsWs?key=UMdHdUL4IHw5n8uioKW5hhK4" alt=""><figcaption></figcaption></figure></div>

<div data-full-width="false"><figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfclBlX48IOh40H0uaDG6RupOplbgJRFIDkSxNHZjKMDF7PxE6woX64LVObk9OW0ALMDX6yZiJNrBnj0KwHxkBzDULRHgYyd0sYUSzYDOJJlr5xXQOAW4q6Cws2r435NlsjZKiLJg?key=UMdHdUL4IHw5n8uioKW5hhK4" alt=""><figcaption></figcaption></figure></div>

In the Application.cs, we are building an event to invoke the ShowNotification.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXflJiECAmWVDk2pTWd8NOqngxGYwGTJVmaZFcqv9zOYWHaFjIzvIqXQ50fn1JXERGMT2WSMUmB1vpv_Ej7E8BqK3p5476prm1H0dz3tWcT7yCmU6p7IAGq07si1iDgeV4gNJopG?key=UMdHdUL4IHw5n8uioKW5hhK4" alt=""><figcaption></figcaption></figure>

In the migrated code, we can replace a simple MessageBox.Show by a Application.CurrentApplication.ShowNotification()

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXe-9ai0pxfnjf6wHg-_5zhOBPTGBVAmh2bNVdSdZmJpxyRNqNWtGv6b8lR3XDVhesAlBSiScyluswMfAD8PNp7zwLscs7OmYiz4mWOwaDeZAl2kXVFBMXmX9jzfP_SbNuerwlu5?key=UMdHdUL4IHw5n8uioKW5hhK4" alt=""><figcaption></figcaption></figure>

By doing this, we don’t need to change anything else (initially) in the migrated razor files. Just a replace during migration (and using the DCP changes)

This should be the result when showing the notification in an web environment application:

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXd3mVk5TPx80Zsfo86CFYh3GTqgSrImCbtlZiw7XGlybNUvPHX5iE-etmruFqXnojtUFdP3sf6RQ9dlzIyRK5HnaBcquNVo7az4NWtiR-ncz7vPdUBa7pD__8VjcVSnYYSV5177Jw?key=UMdHdUL4IHw5n8uioKW5hhK4" alt=""><figcaption></figcaption></figure>
