Gaz*_*wan 1 javascript asp.net
我想在asp.net 4的警告框中显示异常.但它没有显示任何警报.我试过这些解决方案 -
try{// my code}
catch (Exception ex)
{
//Response.Write("<script>alert('" + Server.HtmlEncode(ex.Message) + "')</script>"); // Not Working
//Response.Write("<script>alert('" + ex.Message + "');</script>"); // Not working
// Response.Write("<script>alert('" + Server.HtmlEncode(ex.ToString()) + "')</script>"); // Not working
//ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "done", "alert('Error Occured.');", true); // Only this is working.
}
Run Code Online (Sandbox Code Playgroud)
如果我出错,请建议任何解决方案.
谢谢和问候,Rizwan Gazi.
通常Response.Write();总是有效.但正如你所说它不起作用
试试这个 :
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "done", "alert('" + ex.Message.Replace("'", "") + "');", true);
Run Code Online (Sandbox Code Playgroud)
如果它能解决您的问题,请告诉我.
| 归档时间: |
|
| 查看次数: |
886 次 |
| 最近记录: |