message box show in debug mode.why does not show in localhost?

1.1k Views Asked by At

I am used message box in visual studio 2010. It works in debug mode but does not work on the server. Why does it not work?

if (MessageBox.Show("Invoice sample already exists. Do you want to overwrite it?.", "Overwrite", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification) == DialogResult.OK)
{

    dr.Close();
    con.Close();
    con.Open();
    cmd = new SqlCommand("sp_pdm_shopping_upload_update", con);
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add(new SqlParameter("@sample", SqlDbType.Char, 10));
    cmd.Parameters.Add(new SqlParameter("@image", SqlDbType.Image));
    cmd.Parameters.Add(new SqlParameter("@type", SqlDbType.Char, 10));
    cmd.Parameters["@sample"].Value = txt_code.Text;
    cmd.Parameters["@image"].Value = imgbyte;
    cmd.Parameters["@type"].Value = "INV";
    cmd.ExecuteNonQuery();
    con.Close();
    //getuploadinvoice();
    //getuploadimage();
    ErrorMsg.Visible = true;
    ErrorMsg.Text = "The image has been successfully updated.";


}
2

There are 2 best solutions below

1
On

Of course it doesn't show up. You are not guaranteed to even have a terminal on which to show a message box from an ASP.NET application. They are intended only for windows client applications, not web applications.

Instead of using a message box, write your debug info to a log file instead. If you google for it you'll find many examples of how to do that.

If you need user confirmation, as it appears from the comments, then use a javascript confirmation dialog as @AdrianSalazar suggests in his answer.

0
On

On your HTML button you should put a javascript code. For example:

<input type="button" value="Save" onclick="return confirm('Invoice sample already exists. Do you want to overwrite it?.')" />

Then in your server side just act normally. Only the users who accepted the dialog box should reach your server side function.