Reputation: 63
Iam using this code.
DialogResult result = MessageBox.Show("Do you want to save changes?", "Confirmation", MessageBoxButtons.YesNoCancel);
if (result == DialogResult.Yes)
{
//...
}
else if (result == DialogResult.No)
{
//...
}
else
{
//...
}
It throws me an error:
The type of namespace name 'DialogResult' could not be found (Are you missing a using directive or an essembly reference?)
How to fix it? Thank you.
Upvotes: 0
Views: 2788
Reputation: 11
The answer of a MessageBox is a MessageBoxResult, not DialogResult. (DialogResult is for older, like FileOpen Dialogs). Change "DialogResult" in your code to "MessageBoxResult", and it will rub.
Upvotes: 1
Reputation: 1796
You've tagged your question with asp.net
and what you are trying to do is not possible in asp.net
, you can choose the alternative of doing this by using Javascript
, put the JS
code in whatever event handler you are using. If you are using on some button click handler then put this one on your OnClientClick
OnClientClick="return confirm('Do you want to Save changes?');"
It will return true if user click on OK and false if clicks on Cancel.
Hope it helps.
Upvotes: 0
Reputation: 245399
Did you add the reference to System.Windows.Forms.dll
to your project as well as import System.Windows.Forms
in your source?
Upvotes: 0