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()