You can not use a message box in a web application. The code is running on the server, the application is viewed thru the client browser. If you *could* launch a message box only someone sitting at the server console would see it. The user viewing thru the browser will not see it.
The error you get when you try to do this when it's running on IIS is "Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation..."
It works when you are developing because the web server you are using (built-in development web server) IS running in UserInteractive mode. It's running on your desktop in the system task tray. This leads to the false perseption that you can legally do this with a web application.
You need to use client side script if you want to present the user with a messagebox-like interface. This is accomplished with the javascript "alert()" method. You can emit this javascript to the browser "on-demand" with server-side that looks like this:
Page.ClientScript.RegisterStartupScript(this.GetTy pe(), "MyMessageBoxScript", "alert('Hello World');", true);
This will emit the script to the client after the postback and the browser will execute it after the page is loaded, showing the alert dialog.
-
Peter