How to display an error message box in a web application asp.net c#

后端 未结 7 1382
小蘑菇
小蘑菇 2020-12-03 18:28

I have an ASP.NET web application, and I wanted to know how I could display an error message box when an exception is thrown.

For example,

                 


        
7条回答
  •  感动是毒
    2020-12-03 19:05

    using MessageBox.Show() would cause a message box to show in the server and stop the thread from processing further request unless the box is closed.

    What you can do is,

    this.Page.ClientScript.RegisterStartupScript(this.GetType(),"ex","alert('" + ex.Message + "');", true);
    

    this would show the exception in client side, provided the exception is not bubbled.

提交回复
热议问题