比如我想单击一个按键就会出一个框,代码如下~~
private void Button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("You must enter a name.", "Name Entry Error",MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
但是单击后出错:
异常详细信息: System.InvalidOperationException: 在应用程序未以 UserInteractive 模式运行的情况下显示有模式对话框或窗体是无效的操作。请指定 ServiceNotification 或 DefaultDesktopOnly 样式,以显示服务应用程序发出的通知。我是一个初学者,看不明白,希望大家帮帮小弟我~~如果需要增加代码麻烦写一下,谢谢~~

解决方案 »

  1.   

    工程里填加System.Windows.Forms引用,试试..
      

  2.   

    System.Windows.Forms不加的话,编译是通不过的吧.是不是在WEB下面运行这个了?
      

  3.   

    System.Windoos.Forms
    这个我已经加了的啊!!
      

  4.   

    private void Button1_Click(object sender, System.EventArgs e)
    {
    MessageBox.Show("You must enter a name.", "Name Entry Error",MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    }我把代码放到一个新建的项目后运行,它不会出异常详细信息,但是怎么单击都是没反应的~~根本不出框来~~
      

  5.   

    MessageBox.Show("You must enter a name.", "Name Entry Error",MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    也许是这句错了,好好看看帮助
    MessageBoxButtons.OKCancel 
    MessageBoxButtons.YesNo
      

  6.   

    webForm弹出框不是用MessageBox吧
      

  7.   

    MessageBoxButtons.OK是没错的啊~~
    如果不是用MessageBox那应该怎么写呢?指教一下~谢谢~~
      

  8.   

    webForm下不能用winForm的messagebox
      

  9.   

    那么应该怎么样在webForm下实现弹出框的功能呢?
      

  10.   

    Response.Write("<script language='JavaScript'>window.alert('提示信息');</script>")
      

  11.   

    带取消的:
    confirm('您真的要删除此记录吗?')
      

  12.   

    第二个问题:
    在弹出页面中执行,就是当前页面了。这个不能写成通用的。
    Response.Write("<script language='JavaScript'>window.alert('提示信息');</script>")
      

  13.   

    取消的应当是:
    return confirm('您真的要删除此记录吗?')
      

  14.   

    return confirm('您真的要删除此记录吗?')
    这句代码应该怎么加呢?我是这个学期才开始学编程,麻烦这么多次实在抱歉~~
      

  15.   

    下面这句在Form_page()中运行
    你的按钮.Attributes.Add("onclick", "return confirm('您真的要删除此记录吗?')");
      

  16.   

    Attributes.Add("onclick", "return confirm('您真的要删除此记录吗?')");
    我见过这句代码,原来用法是前面还要加个控件名~~现在我懂了~~
    谢谢谢谢`~非常感谢chsl918你帮了我这么多次~~也学会了很多~~
      

  17.   

    http://blog.csdn.net/netcpl/archive/2006/09/15/1227645.aspx