catch (Exception err)
{
//这句代码如何写,实现弹出窗口提示错误?}

解决方案 »

  1.   

    Response.Write("<script type=text/javascript>alert('提示错误!!!');</script>");
      

  2.   

    我说的是把err.message信息以弹出窗口的形式显示出来。不知道该怎么写?
      

  3.   

    form环境:
    System.window.form.MessageBox.show(err.Message);
      

  4.   

    忘了告诉大家,我用的环境是vs.net2005,用的是b/s架构
      

  5.   

    看不明白,蹭点分
    try
    {
        int i = 0;
        i = 1 / i;
    }
    catch (Exception err)
    {
        MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 
    }
      

  6.   

     protected void Page_Load(object sender, EventArgs e)
        {
            try { int i = 0; i = 1 / i; }
            catch (Exception err) {
                ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
                    string.Format("window.alert('{0}')", err.Message), true);
            }
        }
      

  7.   

    vs.net2005是不支持messagebox的,上面写的太复杂了。
    我说的是:if()
    {}
    catch(Exception err)
    {
    //把err弹出窗口语句写在这里
    }
    finaly
    {}
      

  8.   

    我还没在任何开发语言中见过if ...catch的写法,如果你诚心提问就先准备好自己的测试环境不要浪费大家的时间
      

  9.   

    不好意思,写错了
    我想写的是:try() 
    { } 
    catch(Exception err) 

    //把err弹出窗口语句写在这里 

    finaly 
    { }
      

  10.   

    try { }
            catch (Exception err) {
                ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
                    string.Format("window.alert('{0}')", err.Message), true);
            }
    finaly 
    { }
      

  11.   

    catch (Exception err)
    {
        MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 
    }
      

  12.   

    问题是怎么弹出这个对话框
    错误信息都不重要//Page为本页面名
    //displayResult为要显示字符串
    Page.RegisterHiddenField("displayResult", displayResult);script = "<script language='javascript'>" + 
             "window.onload=function(){ if(document.getElementById('displayResult').value != \"\") alert(document.getElementById('displayResult').value)} </script>";
    //进行显示
    Page.RegisterStartupScript("DisplayResult", script);这是基本的脚本
      

  13.   

    Response.Write("<script defer>alert('"+err.Message+"')</script>");
      

  14.   

    感谢大家的热心,大家回答的时候最好是大家用过时正确的或则是自己能肯定是对的,在发帖,因为我看了大家的帖子,好像都不太对,vs.net2005不支持messagebox了,不知道大家了解不?
      

  15.   

    Response.Write(" <script type=text/javascript>alert('" + err.Message + "'); </script>");