警告不在asp.net 4中显示异常变量 [英] alert not showing exception variable in asp.net 4

查看:66
本文介绍了警告不在asp.net 4中显示异常变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



我想在asp.net 4的警告框中显示异常。但它没有显示任何警报。我试过这些解决方案 -

试试{//我的代码}

catch(Exception ex)

{

//Response.Write(alert('+ Server.HtmlEncode(ex.Message)+')); //不工作//Response.Write(alert('+ ex.Message +');); //不工作

// Response.Write(alert('+ Server.HtmlEncode(ex.ToString())+')); //不工作// ScriptManager.RegisterStartupScript(this.Page,this.GetType(),done,alert('Error Occured。');,true); //只有这个才有效。

}



如果我出错,请建议任何解决方案。



谢谢和问候,

Rizwan Gazi。

Dear all,

I want to show exception in alert box in asp.net 4. But it is not showing any alert. I tried these solutions -
try{// my code}
catch (Exception ex)
{
//Response.Write("alert('" + Server.HtmlEncode(ex.Message) + "')"); // Not Working //Response.Write("alert('" + ex.Message + "');"); // Not working
// Response.Write("alert('" + Server.HtmlEncode(ex.ToString()) + "')"); // Not working //ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "done", "alert('Error Occured.');", true); // Only this is working.
}

Please suggest any solution to this where I am going wrong.

Thanks and regards,
Rizwan Gazi.

推荐答案

ScriptManager.RegisterStartupScript(this.Page, this.GetType(),CreateExamError,alert('+ ex.Message.Replace(',)+');,true);



我必须在警报中使用替换功能。
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "CreateExamError", "alert('" + ex.Message.Replace("'", "") + "');", true);

I had to use Replace function in alert.


  try
   {
     int a, b, c;
     b = 0;
     a = 10;
     c = a / b;

  }
catch (Exception ex)
 {

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


这篇关于警告不在asp.net 4中显示异常变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆