0

Error message in web

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.

Mycode

using System.Windows.Forms;

protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
      var confirmResult = MessageBox.Show("Are you sure to delete thisitem??",
                                            "Confirm Delete!!",
                                            MessageBoxButtons.YesNo);
      if (confirmResult == DialogResult.Yes)
      {
          string terminal_id = GridView2.DataKeys[e.RowIndex].Value.ToString();
          selectTerminal();
          deleteTerminal(terminal_id);
      }
      else
      {
                // If 'No', do something here.
      }
 }
Hari Prasad
  • 16,716
  • 4
  • 21
  • 35
  • 1
    Did you check: http://stackoverflow.com/questions/8928713/how-to-resolve-error-showing-a-modal-dialog-box-or-form-when-the-application-i – ewitkows Aug 17 '16 at 02:28
  • Is this code in a web page? If so MessageBox is part of Windows Forms so will not work in the web - if your expecting to see it in a browser. – Andez Aug 17 '16 at 11:45

1 Answers1

-1

var confirmResult = MessageBox.Show("Are you sure to delete thisitem??", "Confirm Delete!!", MessageBoxButtons.YesNo, MessageBoxIcon.None);

try using this :)