I am trying to add a confirmation messagebox in C# code and the examples I have found and I have added the below example but I keep getting error message "The name 'MessageBox' does not exist in the current context" I am pretty new to C# and need help as I need a confirmation message for the user of the page.
I have tried adding the Using system.windows.form to see if that resolves the messagebox issue but so far no luck
const string message = "Are you sure that you would like to close the form?";
const string caption = "Form Closing";
var result = MessageBox.Show(message, caption,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
// If the no button was pressed ...
if (result == DialogResult.No)
{
// cancel the closure of the form.
e.Cancel = true;
}
Based on a compare I will perform, I will need this messagebox to prompt and ask the user if they are sure they want to continue or not and if not it is to return to the page, if so then the new code executes.