当前位置: 代码迷 >> ASP.NET >> 異常處理,catch(Exception ex)中的ex.Message怎樣在alert中調用到?解决思路
  详细解决方案

異常處理,catch(Exception ex)中的ex.Message怎樣在alert中調用到?解决思路

热度:5988   发布时间:2013-02-26 00:00:00.0
異常處理,catch(Exception ex)中的ex.Message怎樣在alert中調用到?
...
    catch(Exception   ex)
    {
        Response.Write(@ " <script> javascript:alert( 'System   is   wrong,wrong   is   ' "+ex.Message+ " '! ') </script> ");
    }
在上面代碼中,Response.Write(@ " <script> javascript:alert( 'System   is   wrong,wrong   is   "+ex.Message+ "! ') </script> ");寫得不行,會出錯,請問怎樣用javascript的alert拋出詳細異常ex.Message?

謝謝!


------解决方案--------------------------------------------------------
如果还不行。string errMsg= "System is wrong,it is "+ex.Message;errMsg = errMsg.Replace( "\r\n ", "\\r\\n ");errMsg = errMsg.Replace( " ' ", "\\ ' ");
  相关解决方案