All you have to do is, throw the error in the child class.
Suppose you have
class
called
Business as
public class Business
{
public string SomeMethod()
{
try
{
int x = 0;
int a = 5 / x;
}
catch (Exception)
{
throw;
}
return "";
}
}
and you are calling it from a page..
protected void Page_Load(object sender, EventArgs e)
{
try
{
Business obj = new Business();
obj.SomeMethod();
}
catch (Exception ex)
{
ShowMessage(ex.Message);
}
}
Helper funciton to show message from cs file
public void ShowMessage(string message)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload=function(){");
sb.Append("alert('");
sb.Append(message);
sb.Append("')};");
sb.Append("</script>");
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
}