J
Jesper Stocholm
It was my impression, that .Net supported Error-bubbling, that is, any
errors would - without error-handling - be transported to the upper
class. However, it doesn't seem to be so.
The case is:
I have an ASP.Net-page that loads some controls to render content to
the page. Some of these controls retrieve data from a database, and
is therefore prone to any db-errors.
I would like to show the error on the page in a specific placeholder
(literal) så that it doesn't mess up the layout. I could implement
error-handling in the ascx-file itself, but then I cannot place the
error message correctly on the page, since the control doesn't have
access to the data on the page.
So I wrote the following code for my ASP.Net page:
private void Page_Load(object sender, System.EventArgs e)
{
LoadControls();
}
private void LoadControls()
{
try
{
divLeft.Controls.Add(Page.LoadControl("~/controls/search.ascx"));
}
catch (Exception e)
{
this.ErrorDescription = e.Message;
}
}
this.ErrorDescription is a member of the template page class my
pages all inherit from.
I thought that this would catch any problems ocurring in the
controls, but it doesn't. If I induce any errors in the controls,
the entire page crashes.
Am I missing something, or what should I do to fix it?
Thanks,
errors would - without error-handling - be transported to the upper
class. However, it doesn't seem to be so.
The case is:
I have an ASP.Net-page that loads some controls to render content to
the page. Some of these controls retrieve data from a database, and
is therefore prone to any db-errors.
I would like to show the error on the page in a specific placeholder
(literal) så that it doesn't mess up the layout. I could implement
error-handling in the ascx-file itself, but then I cannot place the
error message correctly on the page, since the control doesn't have
access to the data on the page.
So I wrote the following code for my ASP.Net page:
private void Page_Load(object sender, System.EventArgs e)
{
LoadControls();
}
private void LoadControls()
{
try
{
divLeft.Controls.Add(Page.LoadControl("~/controls/search.ascx"));
}
catch (Exception e)
{
this.ErrorDescription = e.Message;
}
}
this.ErrorDescription is a member of the template page class my
pages all inherit from.
I thought that this would catch any problems ocurring in the
controls, but it doesn't. If I induce any errors in the controls,
the entire page crashes.
Am I missing something, or what should I do to fix it?
Thanks,