Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Trapping exceptions encountered in user controls

Reply
Thread Tools

Trapping exceptions encountered in user controls

 
 
Yash
Guest
Posts: n/a
 
      01-17-2008
Hi,

I have create a user control which has a dropdown. The user control
internaly handles the Selected_Index_Changed event of the dropdown. If
there is an error/exception in handling it, I would like the
containing page to know of it. How can I make this possible? The
containing page does not know of the dropdown.

Thanks,
Yash
 
Reply With Quote
 
 
 
 
JIGNESH
Guest
Posts: n/a
 
      01-17-2008
To give you an idea therotically.
1. Declare event in your usercontrol.
2. From your page trap the event UserControl += new MyEvent( ...... )
3. OnException inside UserControl Raise the Event
4. You Page event handdler will receive the event and execute your function.

if you find difficult then i shall spend sometime to code and post it here.

Regards
JIGNESH

"Yash" wrote:

> Hi,
>
> I have create a user control which has a dropdown. The user control
> internaly handles the Selected_Index_Changed event of the dropdown. If
> there is an error/exception in handling it, I would like the
> containing page to know of it. How can I make this possible? The
> containing page does not know of the dropdown.
>
> Thanks,
> Yash
>

 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      01-17-2008
It doesn't matter. The exception bubbles and will be handled at the parent
level inside the hosting application (make sure you don't hide the exception
in your user control ???)...
--
Patrice


"Yash" <(E-Mail Removed)> a écrit dans le message de news:
eb94425e-79a2-4dc2-8081-c0347eeb7ac2...oglegroups.com...
> Hi,
>
> I have create a user control which has a dropdown. The user control
> internaly handles the Selected_Index_Changed event of the dropdown. If
> there is an error/exception in handling it, I would like the
> containing page to know of it. How can I make this possible? The
> containing page does not know of the dropdown.
>
> Thanks,
> Yash



 
Reply With Quote
 
Yash
Guest
Posts: n/a
 
      01-17-2008
But where will the try and catch be in the containg page to handle the
bubbled exception?

Raising an OnError event may work. But is there another way?
 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      01-17-2008
Either in the Page_Error event or in the global exception event handler (my
personal preference)...

The general idea is that exceptions are propagated automatically to callers.
So the first step could be to check your first assumption. This is not
because the dropdown is not an object known from the parent page that
exceptions thrown there are not propagated back to the caller (it just uses
the call stack to pass the exception to calling code).

With this in mind the general principle would be to have a global error
handler at the highest possible level so that you knows that something goes
wrong and that you can fix the coding error. Then you can place a local
exception handler at choosen places :
- either because your code or the user could do something to solve the
particular exception you are trapping at this place (and in this case you
don't let this particular one to propagate higher)
- or to do some cleanup on unmanaged resources (but in this case you still
let the exception goes higher as once resources are released you still want
to know that your application has en error you should fix).

You should find more details areound :
http://msdn2.microsoft.com/en-us/library/6kzk0czb.aspx

--
Patrice



"Yash" <(E-Mail Removed)> a écrit dans le message de news:
3b2db41c-5364-4869-a575-dfe46f8a85a7...oglegroups.com...
> But where will the try and catch be in the containg page to handle the
> bubbled exception?
>
> Raising an OnError event may work. But is there another way?



 
Reply With Quote
 
Yash
Guest
Posts: n/a
 
      01-18-2008

Thanks
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
searching what groups a user belong from AD but errorThe Kerberos subsystem encountered an error. A service for user protocol request was made rote ASP .Net Security 13 01-04-2008 06:20 AM
Trapping Exceptions on an ObjectDataSource =?Utf-8?B?SmVyZW15IEJyb3du?= ASP .Net 1 03-09-2006 05:52 PM
Trapping the <BODY> onUnload() / Detecting when a user closes the browser =B= ASP .Net 3 09-30-2004 08:20 AM
Trapping Perl divide-by-zero exceptions using eval( ) Griff Perl Misc 2 08-27-2004 04:53 PM
Urgent...trapping User's Browser closing event.... Chirag Malvi ASP .Net 1 11-11-2003 03:33 PM



Advertisments