Ask a Question related to ASP.NET General, Design and Development.
-
KJ #1
Throwing Exception in a composite control
This is kind of hard to explain but I have a [composite control] The
controls are created with CreateChildControls(). Now let say I click a
button and an error occurs in the control. If I throw it up it goes
back to the web form. where do I catch the exception at?
Example
Webform
Composite Control
but_click
Throw e as exception
Then the exception goes back up the chain until it gets to the
webform. Can I catch the exception in any event on the webform?
Because after it get pass the control the chain is broken.
Or do I have to pass it as a parameter like RaiseEvent Click(Me, e,
exception)?
I hope this is clear. If anyone know of a good resource for throwing
exception from composite controls let me know.
KJ Guest
-
PDDOCSAVE -throwing unhandled exception
Hi Everybody, When i am using PDDOCSAVE in my application to secure a file using Acrobat 9.0 in VC++ i am getting unhandled exception The code... -
#32101 [Com]: Exception in unknown on line 0 when throwing exception inside exception handler
ID: 32101 Comment by: dhopkins at DonHopkins dot com Reported By: ceefour at gauldong dot net Status: No... -
#40033 [NEW]: Server Crashes when Throwing an Exception
From: francisco dot a dot castillo at ge dot com Operating system: Linux Fedora Core 6 PHP version: 5.2.0 PHP Bug Type: ... -
#40033 [Opn->Fbk]: Server Crashes when Throwing an Exception
ID: 40033 Updated by: iliaa@php.net Reported By: francisco dot a dot castillo at ge dot com -Status: Open... -
Possible to create a composite control that has a child control that is a validator that validates the composite control itself?
I am attempting to create a composite control which has a label, followed by an optional error message, followed by two text boxes. I have... -
John Saunders #2
Re: Throwing Exception in a composite control
Does your control know how to handle the exception? Then it should catch the
exception in the catch block of a try-catch statement. The exception should
be caught where it can be handled.
If your control doesn't know what to do with the exception, then leave it
alone. It's up to the person who knows how to handle the exception to have
the exception handler.
BTW, this has nothing at all to do with composite controls. This is a basic
matter of one method calling another,. which calls another - which raises an
exception. Exception processing does nothing special with the control
hierarchy.
--
John Saunders
Internet Engineer
[email]john.saunders@surfcontrol.com[/email]
"KJ" <klj_mcsd@hotmail.com> wrote in message
news:d83a9214.0307231343.6a4ae279@posting.google.c om...> This is kind of hard to explain but I have a [composite control] The
> controls are created with CreateChildControls(). Now let say I click a
> button and an error occurs in the control. If I throw it up it goes
> back to the web form. where do I catch the exception at?
>
>
> Example
> Webform
>
> Composite Control
>
> but_click
>
> Throw e as exception
>
>
>
> Then the exception goes back up the chain until it gets to the
> webform. Can I catch the exception in any event on the webform?
> Because after it get pass the control the chain is broken.
>
> Or do I have to pass it as a parameter like RaiseEvent Click(Me, e,
> exception)?
>
> I hope this is clear. If anyone know of a good resource for throwing
> exception from composite controls let me know.
John Saunders Guest
-
John Saunders #3
Re: Throwing Exception in a composite control
Why do you think you want to catch it in the webform? What do you expect to
do about such an exception? Are you concerned about some one particular
exception, or just exceptions in general?
Is your control explicitly throwing a particular exception? If so, then
please stop doing that. Exceptions are for exceptional circumstances.
They're not a general non-local goto.
You say it's not that easy with composite controls. You're dead wrong. Your
situation is in no way specific to controls, much less to composite
controls. This is nothing more than a chain of subroutine calls. I strongly
recommend that you stop asking your questions about controls and instead
just ask them about subroutines calling subroutines which call subroutines.
Has this exception ever occurred? In that case, one really big hint will be
the stack trace. Look at the trace and pretend you've never even _heard_
about controls!
If necessary, post the stack trace and I'll become less general. But I'm
concerned that if I do that, you won't learn the real lesson - that this has
nothing whatsoever to do with controls.
--
John Saunders
Internet Engineer
[email]john.saunders@surfcontrol.com[/email]
"Kyle Johnson" <klj_mcsd@hotmail.com> wrote in message
news:%23TnJLTXUDHA.2460@TK2MSFTNGP10.phx.gbl...>
>
> my problem is. Where do I catch the exception in the webform? If the was
> a user control made of of html controls it would be simple but it's not
> that easy with composite controls. I want to catch it at the webform
> level
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
John Saunders Guest
-
John Saunders #4
Re: Throwing Exception in a composite control
Kyle,
First, like I said, you should abstract the problem away from "controls" and
"web forms" to "components" and "component consumers".
However, you were given a good suggestion, one which would work whether this
were a "control" issue or a "component" issue. Your control should define an
Error event with the exception as a parameter. btnSearchClick (NOT "Search")
should catch any exceptions and should raise them as Error events to whoever
cares about Error events. Possibly even your Web Form.
--
John Saunders
Internet Engineer
[email]john.saunders@surfcontrol.com[/email]
"Kyle Johnson" <klj_mcsd@hotmail.com> wrote in message
news:eWy6tMeUDHA.2004@TK2MSFTNGP10.phx.gbl...>
>
> Thank you for your help. I will post my stack trace. That might explain
> my situation better. I'm not at work today so it will be tomorrow. Thank
> you again
>
>
> But just to let you know someone told me to pass the exception back as a
> parameter in the event that gets raised to the webform. That does not
> sound like the best way to do it.
>
> Another example
>
> Control
>
> AddHandler btnSearch.Click AddressOf btnSearchClick
>
> Sub btnSearchClick()
> onclick()
> End Sub
>
>
> ..... Sub OnClick()
>
> Search()
>
> End Sub
>
>
> Sub Search()
>
>
> Try
> .
> .
> .
> Catch
> .
> .
> .
> Throw New Exception(e.Message)
>
> End Sub
>
>
> When I click thesearch button on the control and If an exception occurs
> in Search() and I need to get it to the webform that the control is in,
> so a custom error object can handle it. How do I get it there?
>
> Thanks again
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
John Saunders Guest
-
Kyle Johnson #5
Re: Throwing Exception in a composite control
Can you explain what you mean by 'error events'? I'm fairly new to this.
Thanks for your help.
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Kyle Johnson Guest
-
John Saunders #6
Re: Throwing Exception in a composite control
I meant an event called "Error" which is raised to indicate that an error
has occurred. Such an event can be handled by any number of pieces of code
which care whether an error has occurred.
--
John Saunders
Internet Engineer
[email]john.saunders@surfcontrol.com[/email]
"Kyle Johnson" <klj_mcsd@hotmail.com> wrote in message
news:%232DrYZkUDHA.1396@tk2msftngp13.phx.gbl...> Can you explain what you mean by 'error events'? I'm fairly new to this.
> Thanks for your help.
>
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
John Saunders Guest



Reply With Quote

