By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,930 Members | 1,465 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,930 IT Pros & Developers. It's quick & easy.

Urgent User Control

P: n/a
Hi All,

I have a requirement. I am throwing an exception from my user control I want
to catch this in my container page. Is this possible?

I don't want any event to be raised.

PLEASE HELP ME.

Thanks

Prince
Nov 19 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Here's how exceptions work. When a function calls another function that
calls another function that raises an exception, the final function raises
the exception. If the exception is not handled by that function, it will
cause the exception to "bubble up" to the function that called the function
that raised the exception. This will happen until either (1) the exception
is handled at some point in the chain, or (2) the application thread is
aborted due to an unhandled exception.

Knowing this, of course, your solution is obvious.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:O9**************@TK2MSFTNGP15.phx.gbl...
Hi All,

I have a requirement. I am throwing an exception from my user control I
want to catch this in my container page. Is this possible?

I don't want any event to be raised.

PLEASE HELP ME.

Thanks

Prince

Nov 19 '05 #2

P: n/a
Kevin,

I know how exception handling works. But my question is how will you catch
an exception thrown from the User Control. Say you are throwing an exception
from the Page_Load of the user control.Where will you put the try catch in
the container page.

Thanks
Prince

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:u9**************@TK2MSFTNGP15.phx.gbl...
Here's how exceptions work. When a function calls another function that
calls another function that raises an exception, the final function raises
the exception. If the exception is not handled by that function, it will
cause the exception to "bubble up" to the function that called the
function that raised the exception. This will happen until either (1) the
exception is handled at some point in the chain, or (2) the application
thread is aborted due to an unhandled exception.

Knowing this, of course, your solution is obvious.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:O9**************@TK2MSFTNGP15.phx.gbl...
Hi All,

I have a requirement. I am throwing an exception from my user control I
want to catch this in my container page. Is this possible?

I don't want any event to be raised.

PLEASE HELP ME.

Thanks

Prince


Nov 19 '05 #3

P: n/a
If you don't want to bubble up an event in the UserControl, your best option is to catch the error in Page_Load event. Alternatively, you can load the control at runtime(dynamically) and catch the exception in that method.

Thanks,
Prodip
www.aspnet4you.com
"Prince Mathew" <pr****************@hotmail.com> wrote in message news:u3*************@TK2MSFTNGP10.phx.gbl...
Kevin,

I know how exception handling works. But my question is how will you catch
an exception thrown from the User Control. Say you are throwing an exception
from the Page_Load of the user control.Where will you put the try catch in
the container page.

Thanks
Prince

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:u9**************@TK2MSFTNGP15.phx.gbl...
Here's how exceptions work. When a function calls another function that
calls another function that raises an exception, the final function raises
the exception. If the exception is not handled by that function, it will
cause the exception to "bubble up" to the function that called the
function that raised the exception. This will happen until either (1) the
exception is handled at some point in the chain, or (2) the application
thread is aborted due to an unhandled exception.

Knowing this, of course, your solution is obvious.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:O9**************@TK2MSFTNGP15.phx.gbl...
Hi All,

I have a requirement. I am throwing an exception from my user control I
want to catch this in my container page. Is this possible?

I don't want any event to be raised.

PLEASE HELP ME.

Thanks

Prince




Nov 19 '05 #4

P: n/a
> I know how exception handling works. But my question is how will you catch
an exception thrown from the User Control.
Classes don't throw exceptions. Functions do.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:u3*************@TK2MSFTNGP10.phx.gbl... Kevin,

I know how exception handling works. But my question is how will you catch
an exception thrown from the User Control. Say you are throwing an
exception from the Page_Load of the user control.Where will you put the
try catch in the container page.

Thanks
Prince

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:u9**************@TK2MSFTNGP15.phx.gbl...
Here's how exceptions work. When a function calls another function that
calls another function that raises an exception, the final function
raises the exception. If the exception is not handled by that function,
it will cause the exception to "bubble up" to the function that called
the function that raised the exception. This will happen until either (1)
the exception is handled at some point in the chain, or (2) the
application thread is aborted due to an unhandled exception.

Knowing this, of course, your solution is obvious.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:O9**************@TK2MSFTNGP15.phx.gbl...
Hi All,

I have a requirement. I am throwing an exception from my user control I
want to catch this in my container page. Is this possible?

I don't want any event to be raised.

PLEASE HELP ME.

Thanks

Prince



Nov 19 '05 #5

P: n/a
Kevin,
Can you answer my question? Or are you still not clear about the question???

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Oy**************@TK2MSFTNGP15.phx.gbl...
I know how exception handling works. But my question is how will you
catch an exception thrown from the User Control.


Classes don't throw exceptions. Functions do.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:u3*************@TK2MSFTNGP10.phx.gbl...
Kevin,

I know how exception handling works. But my question is how will you
catch an exception thrown from the User Control. Say you are throwing an
exception from the Page_Load of the user control.Where will you put the
try catch in the container page.

Thanks
Prince

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:u9**************@TK2MSFTNGP15.phx.gbl...
Here's how exceptions work. When a function calls another function that
calls another function that raises an exception, the final function
raises the exception. If the exception is not handled by that function,
it will cause the exception to "bubble up" to the function that called
the function that raised the exception. This will happen until either
(1) the exception is handled at some point in the chain, or (2) the
application thread is aborted due to an unhandled exception.

Knowing this, of course, your solution is obvious.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:O9**************@TK2MSFTNGP15.phx.gbl...
Hi All,

I have a requirement. I am throwing an exception from my user control I
want to catch this in my container page. Is this possible?

I don't want any event to be raised.

PLEASE HELP ME.

Thanks

Prince



Nov 19 '05 #6

P: n/a
Prodip,

Have you tried what you have said ????. Page_Load of the user control is executed after the Page_Load of the Page.

Thanks
Prince
"Prodip Saha" <ps***@bear.com> wrote in message news:ee**************@tk2msftngp13.phx.gbl...
If you don't want to bubble up an event in the UserControl, your best option is to catch the error in Page_Load event. Alternatively, you can load the control at runtime(dynamically) and catch the exception in that method.

Thanks,
Prodip
www.aspnet4you.com
"Prince Mathew" <pr****************@hotmail.com> wrote in message news:u3*************@TK2MSFTNGP10.phx.gbl...
Kevin,

I know how exception handling works. But my question is how will you catch
an exception thrown from the User Control. Say you are throwing an exception
from the Page_Load of the user control.Where will you put the try catch in
the container page.

Thanks
Prince

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:u9**************@TK2MSFTNGP15.phx.gbl...
Here's how exceptions work. When a function calls another function that
calls another function that raises an exception, the final function raises
the exception. If the exception is not handled by that function, it will
cause the exception to "bubble up" to the function that called the
function that raised the exception. This will happen until either (1) the
exception is handled at some point in the chain, or (2) the application
thread is aborted due to an unhandled exception.

Knowing this, of course, your solution is obvious.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:O9**************@TK2MSFTNGP15.phx.gbl...
Hi All,

I have a requirement. I am throwing an exception from my user control I
want to catch this in my container page. Is this possible?

I don't want any event to be raised.

PLEASE HELP ME.

Thanks

Prince




Nov 19 '05 #7

P: n/a
Sorry. Prince, you are correct. Page_load event would not be able to catch the exception. I experienced the problem and handled the exception within the UserControl itself. Have you tried to catch the exception in -OnInit method? This is first in the line of Control Execution Lifecycle. I did not try but you may want to give it a try.

However, if you dynamically load the control (why not) you would have much better control over the exception handling. In this case, there would not be any need to register a tagprefix, etc.

Thanks,
Prodip
www.aspnet4you.com

"Prince Mathew" <pr****************@hotmail.com> wrote in message news:eC**************@TK2MSFTNGP12.phx.gbl...
Prodip,

Have you tried what you have said ????. Page_Load of the user control is executed after the Page_Load of the Page.

Thanks
Prince
"Prodip Saha" <ps***@bear.com> wrote in message news:ee**************@tk2msftngp13.phx.gbl...
If you don't want to bubble up an event in the UserControl, your best option is to catch the error in Page_Load event. Alternatively, you can load the control at runtime(dynamically) and catch the exception in that method.

Thanks,
Prodip
www.aspnet4you.com
"Prince Mathew" <pr****************@hotmail.com> wrote in message news:u3*************@TK2MSFTNGP10.phx.gbl...
Kevin,

I know how exception handling works. But my question is how will you catch
an exception thrown from the User Control. Say you are throwing an exception
from the Page_Load of the user control.Where will you put the try catch in
the container page.

Thanks
Prince

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:u9**************@TK2MSFTNGP15.phx.gbl...
Here's how exceptions work. When a function calls another function that
calls another function that raises an exception, the final function raises
the exception. If the exception is not handled by that function, it will
cause the exception to "bubble up" to the function that called the
function that raised the exception. This will happen until either (1) the
exception is handled at some point in the chain, or (2) the application
thread is aborted due to an unhandled exception.

Knowing this, of course, your solution is obvious.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:O9**************@TK2MSFTNGP15.phx.gbl...
Hi All,

I have a requirement. I am throwing an exception from my user control I
want to catch this in my container page. Is this possible?

I don't want any event to be raised.

PLEASE HELP ME.

Thanks

Prince




Nov 19 '05 #8

P: n/a
> Kevin,
Can you answer my question? Or are you still not clear about the
question???
I DID answer it:
Here's how exceptions work. When a function calls another function that
calls another function that raises an exception, the final function
raises the exception. If the exception is not handled by that function,
it will cause the exception to "bubble up" to the function that called
the function that raised the exception. This will happen until either
(1) the exception is handled at some point in the chain, or (2) the
application thread is aborted due to an unhandled exception.

Knowing this, of course, your solution is obvious.

If you want me to spell it out for you, you put a try/catch in whatever
function in the chain that you want to handle the exception. Functions are
called by other functions.

For example, low-level classes generally throw exceptions rather than
catching or handling them. Higher level applications use these classes, and
functions that use them should handle any exceptions thrown by functions in
the low-level classes. Since I don't know the hierarchy in your code, or how
it is designed, I can't tell you specifically in what function to handle the
exception in, or specifically how to handle it.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:eU**************@TK2MSFTNGP12.phx.gbl... Kevin,
Can you answer my question? Or are you still not clear about the
question???

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Oy**************@TK2MSFTNGP15.phx.gbl... I know how exception handling works. But my question is how will you
catch an exception thrown from the User Control.


Classes don't throw exceptions. Functions do.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:u3*************@TK2MSFTNGP10.phx.gbl...
Kevin,

I know how exception handling works. But my question is how will you
catch an exception thrown from the User Control. Say you are throwing an
exception from the Page_Load of the user control.Where will you put the
try catch in the container page.

Thanks
Prince

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:u9**************@TK2MSFTNGP15.phx.gbl...
Here's how exceptions work. When a function calls another function that
calls another function that raises an exception, the final function
raises the exception. If the exception is not handled by that function,
it will cause the exception to "bubble up" to the function that called
the function that raised the exception. This will happen until either
(1) the exception is handled at some point in the chain, or (2) the
application thread is aborted due to an unhandled exception.

Knowing this, of course, your solution is obvious.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:O9**************@TK2MSFTNGP15.phx.gbl...
> Hi All,
>
>
>
> I have a requirement. I am throwing an exception from my user control
> I want to catch this in my container page. Is this possible?
>
> I don't want any event to be raised.
>
> PLEASE HELP ME.
>
>
>
> Thanks
>
> Prince
>
>



Nov 19 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.