消息框不起作用
我有一个例外,我需要一个消息框,
我的消息框可以在本地主机上工作,但不能在服务器上工作,
catch (Exception)
{
MessageBox.Show("Machine Cannot Be Deleted", "Delete from other Places first", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
我怎样才能完成这项工作...谢谢
,有另一种方法可以做到这一点...请帮助...我知道这是一个小问题,但必须完成......
I have an exception where i need to sheo a messagebox
my messagebox works on localhost but not on the server
catch (Exception)
{
MessageBox.Show("Machine Cannot Be Deleted", "Delete from other Places first", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
how can i make this work... thanks
is there another way to do this.... please help.. i know this is a small problem but it needs to be done...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能在 ASP.NET 中使用 Windows 窗体 MessageBox,因为它在服务器端运行,这对于客户端来说毫无用处。
考虑使用 Javascript 警报或其他类型的验证错误。 (也许有一个包含错误消息的隐藏控件,并在 catch 块中切换其可见性或使用 Response.Write 来发出 Javascript 警报)。
像这样的东西(未经测试):
You can't use a Windows Form MessageBox in ASP.NET since it runs on the server side, making it useless for the client.
Look into using a Javascript alert or some other type of validation error. (Maybe have a hidden control with your error message and toggle its Visibility in the catch block or use Response.Write for a Javascript alert).
Something like this (untested):
您必须使用命名空间
System.Windows.Forms
然后您可以使用消息框属性,例如
在其他替代方案中(除了 Brandon 先生提出的方案之外)
a) 使用 javascript
,例如
b) 制作一个像消息框一样工作的自定义函数,
例如
希望这有帮助
You have to use the namespace
System.Windows.Forms
and then you can use Message box propertye.g.
Among the other alternatives (apart from the one Mr.Brandon has proposed)
a) Use javascript
e.g.
b) Make a custom function that will work like a message box
e.g.
Hope this helps