我有一个带有两个按钮和一个文本的消息框。 这是相关代码:
var result = MessageBox.Show("just a text","just a title",MessageBoxButtons.OKCancel,System.Windows.Forms.MessageBoxIcon.Warning,System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.ServiceNotification | System.Windows.Forms.MessageBoxOptions.RightAlign);
if (result == DialogResult.OK)
{
... code ...
}
我的问题是程序自动在“if”中输入代码,弹出消息框甚至没有显示。 即使在我调试它时,我也会看到代码转到“if”行,结果是 DialogResult.OK。
我正在使用网络表单和 ASP.Net。
MessageBox 的命名空间是“System.Windows.Forms”。
我尝试清除缓存甚至 iisreset。
还有什么可以帮助我?
提前谢谢你。
最佳答案
I am using web forms and ASP.Net.
the namespace for the MessageBox is "System.Windows.Forms".
不要那样做。 ASP.NET 站点在服务器上运行,所以没有人可以单击 MessageBox
,即使它会在服务器上弹出。
如果您想向用户显示弹出窗口,则必须使用 Javascript。参见 How to make a simple yes/no popup in ASP.NET that return the result back to my c#? .
关于c# - MessageBox 自动继续,无需按下按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30027484/