Valerie Meunier

Valerie Meunier

  • NA
  • 693
  • 83.5k

cannot show error message

Jun 26 2022 10:40 AM

Hi

In case of error, I want to show it. I tried two different ways, but none of the two works. 

if i do string a = "ok", then both work. Strange, because ex.Message is a string.

Thanks

catch (SqlException ex)
                {
                string a = ex.Message;
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('Error:' + '" + a + "');", true);
                Response.Write("<script>alert('Error' + '" + a + "');</script>");
                }


Answers (3)