Search code examples
c#asp.netmessagebox

Message.Show is not working when webpage is published


I created a ASP.NET project in which I am using MessageBox.Show to show the user if there is an error or something else. But when I published it, it is giving me this err:

Server Error in '/' Application.

Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

Dont know what it means? What the turnaround of it? Thanks!


Solution

  • MessageBox is for use within windows (as opposed to web) applications. It would attempt to open a message box on the server. This is not allowed so that application errors.

    To show a message on the client you would need to use JavaScript - such as alert("message"). You can add styling using something like jQueryUI Dialog.