catch(SqlException ex)
{

Response.Write("<script>alert('"+ex.Message+"');</"+"script>");
   return;
//Global.CloseConnection();
}

解决方案 »

  1.   

    你的代码是要等到所有代码都运行才能看到弹出窗口,如果你不希望弹出窗口后再执行以后的代码,需要加一个return语句:
    ……
    Response.Write("<script>alert('"+ex.Message+"');</"+"script>");
       return;
    ……
      

  2.   

    To nedvedlh(shirley):没有!
    To : songhtao(三十年孤独) && kinglht(爱新觉罗至尊宝) 
       将代码改成如下:
       问题:还是弹不出窗口!(我的目的是想弹出 警告 窗口!)
     catch(SqlException  ex)
     {
     Response.Write("<script>alert('"+"出错:"+ex.LineNumber.ToString()+"\r\n"+"错误信息"+ex.Message+"\r\n"+"');</"+"script>");          
     //When occur Exception,Close the Connection
     return;
     Global.CloseConnection();
     Response.Redirect("ErrorMsg.aspx");
     }
      

  3.   

    catch(SqlException  ex)
     {
     Response.Write("<script>alert('"+"出错:"+ex.LineNumber.ToString()+"\r\n"+"错误信息"+ex.Message+"\r\n"+"');</"+"script>");          
     //When occur Exception,Close the Connection
     return;
     Global.CloseConnection();
                                          //当窗口还同弹出来时已经重定向了 注释下面行
     //Response.Redirect("ErrorMsg.aspx");<-----
     }