C#中的MessageBox显示错误 [英] MessageBox in C# showing error

查看:199
本文介绍了C#中的MessageBox显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试添加MessageBox.Show(Message);,但在我的C#.net Web应用程序(按钮单击方法以及Page_Load中)中找不到它.显示类似

I was attempting to add MessageBox.Show(Message); and it was not found in my C# .net web application (button click method and also in Page_Load).An error showing like

'名称'MessageBox'在当前上下文中不存在'

我是否需要为此添加任何程序集引用? (我正在使用.net framework 4).有其他替代方法吗?

Do I need to add any assembly reference for this? (I am using .net framework 4). Is there any alternative method for this?

推荐答案

使用此方法:

System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('" + Message + "')", true);

希望这项帮助.

这篇关于C#中的MessageBox显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆