-4

i am using to Message box alert and it work fine at developing but when deploying and publishing

    System.Windows.Forms.DialogResult result2 = System.Windows.Forms.MessageBox.Show("msg :\n" + check + "",
    "Warning",
    System.Windows.Forms.MessageBoxButtons.OK,
    System.Windows.Forms.MessageBoxIcon.Question);

    if (result2 == System.Windows.Forms.DialogResult.OK)
    {
        Response.Redirect("xxx.aspx?acname=" + AN + "&bidref=" + BN + "", true);
    }

i get this eror

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. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: 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.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: 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.] System.Windows.Forms.MessageBox.ShowCore(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, Boolean showHelp) +4551083 System.Windows.Forms.MessageBox.Show(String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon) +52 Checklist.Button1_Click(Object sender, EventArgs e) +6665 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +155 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
KAS
  • 1
  • 5
  • 1
    possible duplicate of [ASP.NET Web Application Message Box](http://stackoverflow.com/questions/9720143/asp-net-web-application-message-box) – MarioDS Jun 04 '15 at 18:57

2 Answers2

0

You are attempting to use a MessageBox intended for Windows Forms applications, not for Web applications. The interfaces for the two platforms are entirely different.

David W
  • 10,062
  • 34
  • 60
  • You can't use Winforms.MessageBox directly in a web app. There are, however, *several* approaches available for *simulating* a Message Box in a web application. You can call a javascript alert; you can even hide a
    within your web page and programmatically style/show it when necessary. There are *many* options available.
    – David W Jun 04 '15 at 19:50
0

The Message box control you were using is for windows desktop application, in another word, it runs under interactive mode which means the dialog only pops up on the machine the code runs on, so in your case, if you look at your server which hosts your web application, you could see it pops up there.

So basically you would need to use web based dialog box, you could try Jquery dialog, it is very easy to use, look at here for the demo and code example.

Please mark it as answer if it solves your problem.

Kane Wang
  • 106
  • 1
  • 7
  • i want to make an ok and cancel and i dont think this is availble in Javascript – KAS Jun 04 '15 at 19:40
  • javascript could do window.confirm("text"), it would show ok and cancel. Also if you use Jquery Dialog, you could customize it completely by putting any buttons you want. – Kane Wang Jun 04 '15 at 20:18