Web alert in script c #

0

I'm developing a web system in asp.net and I came across a problem.

In return for your Catchs, I return an error via an alert to the user like this:

try{
...
}
catch(Exception ex){
    Response.Write("<script>alert('Erro ao adicionar valores no banco.');</script>");
}

The problem is that I also use a .cs class that is not related to any page, and it also needs to return some errors, however if I use "Response.Write" nothing happens.

How can I return these errors in the browser?

I have tried the following ways, but I did not succeed:

  • Response.write
  • page.ClientScript.RegisterClientScriptBlock()
  • ScriptManager.RegisterStartupScript()
asked by anonymous 16.01.2017 / 20:17

0 answers