Alert(ex.ToString(), UpdatePanel1) 这样为什么显示不了?
Alert("出错了"), UpdatePanel1) 这样就行public static void Alert(string _Msg, UpdatePanel UP_Name)
{
    //顯示提示信息
    System.Web.UI.ScriptManager.RegisterClientScriptBlock(UP_Name, typeof(UpdatePanel), "AjaxMsgBox", "alert('" + _Msg + "');", true);
}

解决方案 »

  1.   

    if(ex != null)
    System.Web.UI.ScriptManager.RegisterClientScriptBlock(UP_Name, typeof(UpdatePanel), "AjaxMsgBox", "alert('" + ex.ToString() + "');", true);
      

  2.   

    如果在页面中有多个UpdatePanel,如果每个UpdatePanel的UpdateMode都是“always”,
    那么你使用那个UpdatePanel的实例作为参数都可以;如果每个UpdaePanel的UpdateMode=conditional,
    你必须使用正在更新的那个UpdatePanel作为参数,这样脚本才能起作用。 
      

  3.   

    Alert(ex.ToString()), UpdatePanel1)这样呢
      

  4.   

    分析原因如下
    ex.ToString() 里包含了一些引号,括号之类的东西,这样导致你alert()时JS出错,你可以用在
    System.Web.UI.ScriptManager.RegisterClientScriptBlock
    前面加上一句Response.Write 把ex.ToString()输出来观察下
      

  5.   

    打错了Alert('"+ ex.ToString() +"', UpdatePanel1) 
      

  6.   

    ex变量是try catch 中的那个变量吗?如果是 用这个试试ex.Message.ToString()
      

  7.   

    Alert(ex.ToString().Replace("'",""), UpdatePanel1)ex.ToString()里面有'号,要去掉
      

  8.   

    System.Web.UI.ScriptManager.RegisterClientScriptBlock(UP_Name, typeof(UpdatePanel), "AjaxMsgBox", "alert('" + ex.ToString().Replace("\n","").Replace("\r","").Replace("\"","\\\"").Replace("'","\'") + "');", true); 
      

  9.   

    ex.ToString()?
    你这里的ex是什么?
    如果是try..catch块里的(Exception ex)
    那得这样写:
    ex.Message.ToString()
      

  10.   

     Catch ex As Exception
               
                Alert(ex.ToString(), UpdatePanel1)
     
    public static void Alert(string _Msg, UpdatePanel UP_Name)
    {
        //顯示提示信息
       System.Web.UI.ScriptManager.RegisterClientScriptBlock(UP_Name, GetType(UpdatePanel), "AjaxMsgBox", "alert( _Msg );", True);
    }這樣還是不行
    是不是要把string _Msg 改為 Exception _Msg
     Alert(ex.ToString(), UpdatePanel1)這里是這樣調用的嗎?
      

  11.   

     Dim straa As String = ex.ToString().Replace("\n", "").Replace("\r", "").Replace("'", "\'")
     Alert(straa, UpdatePanel1) Public Sub Alert(ByVal _Msg As String, ByVal UP_Name As UpdatePanel)
            '顯示提示信息
            System.Web.UI.ScriptManager.RegisterClientScriptBlock(UP_Name, GetType(UpdatePanel), "AjaxMsgBox", "alert('" & _Msg & "');", True)
        End Sub這樣也不行。。暈
      

  12.   


    Alert(ex.ToString(), UpdatePanel1) 改成Alert(ex.Message.ToString(), UpdatePanel1)
    试试