Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2007, 10:26 AM
Registered User
 
Join Date: Feb 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Exception handling in a custom control

Hello,

I am writing a ASP.Net custom control (vs2005). I am implementing the usual methods such as Render,
LoadPostData etc. and that goes fine.
However, I just cannot find how I should handle exceptions for a custom control in a good way.
I want to be able to catch / thow exceptions in my control, and then catch/show those in the
page my control is in, without getting a error-page.

For example, when I make an event for my control, and I implement
code for this event in the page my control is in. How can I do this in
such a way that I dont get to see the default error page of .NET (and also not a custom error page).
I simply want to catch the exception in my page and (for example) show it in a label or so.
So, something like this below:

public partial class MyPage : System.Web.UI.Page
{
  ..

   public void MyControl1_TestEvent (EventArgs e)
  {
      try
     {
        // ... do something

     }
     catch (Exception ee)
     {
       lblError.Text = ee.Message;
     }

  }
  ..
}

What is the usual way to implement this? How do professional component developers deal with this subject?









Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception Handling NewTitle2007 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 6 August 8th, 2007 04:03 AM
exception handling jay schumacher VB.NET 2002/2003 Basics 1 April 14th, 2006 08:40 AM
Exception handling aldwinenriquez General .NET 0 August 17th, 2005 06:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.