473,509 Members | 7,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exception in the User Control

Hi All,

I have a requirement. I am throwing an exception from the Page_Load of my
user control I want
to catch this in my container page. Is this possible?
The Page_Load of user control is executed after the Page_Load of the page.
So we cannot catch this in the Page_Load of the page. So my question where
in the page i will catch the exception thrown form the user control.

I don't want any event to be raised from the user control.

PLEASE HELP ME.

Thanks

Prince
Nov 19 '05 #1
4 1609
You can have an error handler at the Page level (Page_Error) which catches
the error and does some processing, but it might have other effects
(unwanted ones) on your app. But try it out.

Personally if it is known that error is raised I would either:

-Try to handle it in the UC itself (own error handler there) and not let
Page do anything with it

or

-if Page needs know about it but doesn't need to do more, indeed raise an
event from the UC

And please note that raising exceptions shouldn't be normal logic, but they
would really need to be used in exceptional situations. Maybe you could
redesign it so that Page invokes the action in UC by calling UC's method,
when it could also handle possible exceptions or return data coming from the
method call (which would indicate error case)

But all these depends on what you need to do withing the Page 8there could
be other alternatives as well). Write the error data for user or something?

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:OT**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I have a requirement. I am throwing an exception from the Page_Load of my
user control I want
to catch this in my container page. Is this possible?
The Page_Load of user control is executed after the Page_Load of the page.
So we cannot catch this in the Page_Load of the page. So my question where
in the page i will catch the exception thrown form the user control.

I don't want any event to be raised from the user control.

PLEASE HELP ME.

Thanks

Prince

Nov 19 '05 #2
Hi,

"Write the error data for user or something?" Thats what i want. But with
out handling the error event or raising an event from the UC can i catch
that exception from the container Page.

Thanks
Prince

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:eg**************@TK2MSFTNGP09.phx.gbl...
You can have an error handler at the Page level (Page_Error) which catches
the error and does some processing, but it might have other effects
(unwanted ones) on your app. But try it out.

Personally if it is known that error is raised I would either:

-Try to handle it in the UC itself (own error handler there) and not let
Page do anything with it

or

-if Page needs know about it but doesn't need to do more, indeed raise an
event from the UC

And please note that raising exceptions shouldn't be normal logic, but
they would really need to be used in exceptional situations. Maybe you
could redesign it so that Page invokes the action in UC by calling UC's
method, when it could also handle possible exceptions or return data
coming from the method call (which would indicate error case)

But all these depends on what you need to do withing the Page 8there could
be other alternatives as well). Write the error data for user or
something?

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:OT**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I have a requirement. I am throwing an exception from the Page_Load of my
user control I want
to catch this in my container page. Is this possible?
The Page_Load of user control is executed after the Page_Load of the
page. So we cannot catch this in the Page_Load of the page. So my
question where in the page i will catch the exception thrown form the
user control.

I don't want any event to be raised from the user control.

PLEASE HELP ME.

Thanks

Prince


Nov 19 '05 #3
> But with out handling the error event or raising an event from the UC can
i catch that exception from the container Page.
Nope, because there isn't anything in "middle" that would initiate that
logic from page, or where you could plug your own code (as long as you keep
it withing Load event of the UC). As I said, it would mean a change so that
Page is the responsible for initiating the action (calling the method in UC
which can cause the error) if you want to have try...catch block to handle
it

Exception in Page_Error comes as general Exception type. If you'd want it
typed, you'd need to check the type first and cast to it (if there's chance
for expections of multiple type). Page_Error runs for all unhandled
exceptions.

Maybe you could get around it by assigning the Label or what the error msg
should be written to, as a proprrty from page to the UC, so UC could set it
itself. Or its ID. Anyways, its your call. The responibility goes into two
possible ways here, either Page does the writing or then UC does it. If Page
does it, it needs to get to the exception somehow and these are the means.

-
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU

..

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

"Write the error data for user or something?" Thats what i want. But with
out handling the error event or raising an event from the UC can i catch
that exception from the container Page.

Thanks
Prince

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:eg**************@TK2MSFTNGP09.phx.gbl...
You can have an error handler at the Page level (Page_Error) which
catches the error and does some processing, but it might have other
effects (unwanted ones) on your app. But try it out.

Personally if it is known that error is raised I would either:

-Try to handle it in the UC itself (own error handler there) and not let
Page do anything with it

or

-if Page needs know about it but doesn't need to do more, indeed raise an
event from the UC

And please note that raising exceptions shouldn't be normal logic, but
they would really need to be used in exceptional situations. Maybe you
could redesign it so that Page invokes the action in UC by calling UC's
method, when it could also handle possible exceptions or return data
coming from the method call (which would indicate error case)

But all these depends on what you need to do withing the Page 8there
could be other alternatives as well). Write the error data for user or
something?

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:OT**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I have a requirement. I am throwing an exception from the Page_Load of
my user control I want
to catch this in my container page. Is this possible?
The Page_Load of user control is executed after the Page_Load of the
page. So we cannot catch this in the Page_Load of the page. So my
question where in the page i will catch the exception thrown form the
user control.

I don't want any event to be raised from the user control.

PLEASE HELP ME.

Thanks

Prince



Nov 19 '05 #4
Thanks
Teemu

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:eT**************@TK2MSFTNGP14.phx.gbl...
But with out handling the error event or raising an event from the UC can
i catch that exception from the container Page.


Nope, because there isn't anything in "middle" that would initiate that
logic from page, or where you could plug your own code (as long as you
keep it withing Load event of the UC). As I said, it would mean a change
so that Page is the responsible for initiating the action (calling the
method in UC which can cause the error) if you want to have try...catch
block to handle it

Exception in Page_Error comes as general Exception type. If you'd want it
typed, you'd need to check the type first and cast to it (if there's
chance for expections of multiple type). Page_Error runs for all unhandled
exceptions.

Maybe you could get around it by assigning the Label or what the error msg
should be written to, as a proprrty from page to the UC, so UC could set
it itself. Or its ID. Anyways, its your call. The responibility goes into
two possible ways here, either Page does the writing or then UC does it.
If Page does it, it needs to get to the exception somehow and these are
the means.

-
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU

.

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

"Write the error data for user or something?" Thats what i want. But with
out handling the error event or raising an event from the UC can i catch
that exception from the container Page.

Thanks
Prince

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:eg**************@TK2MSFTNGP09.phx.gbl...
You can have an error handler at the Page level (Page_Error) which
catches the error and does some processing, but it might have other
effects (unwanted ones) on your app. But try it out.

Personally if it is known that error is raised I would either:

-Try to handle it in the UC itself (own error handler there) and not let
Page do anything with it

or

-if Page needs know about it but doesn't need to do more, indeed raise
an event from the UC

And please note that raising exceptions shouldn't be normal logic, but
they would really need to be used in exceptional situations. Maybe you
could redesign it so that Page invokes the action in UC by calling UC's
method, when it could also handle possible exceptions or return data
coming from the method call (which would indicate error case)

But all these depends on what you need to do withing the Page 8there
could be other alternatives as well). Write the error data for user or
something?

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
"Prince Mathew" <pr****************@hotmail.com> wrote in message
news:OT**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I have a requirement. I am throwing an exception from the Page_Load of
my user control I want
to catch this in my container page. Is this possible?
The Page_Load of user control is executed after the Page_Load of the
page. So we cannot catch this in the Page_Load of the page. So my
question where in the page i will catch the exception thrown form the
user control.

I don't want any event to be raised from the user control.

PLEASE HELP ME.

Thanks

Prince



Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3996
by: Jim O'Neil [Sybase] | last post by:
In designing a new control for general use, I have come across a design decision involving exceptions... I know that TargetSite returns the name of the method that threw the exception; however,...
3
2931
by: Professor Frink | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
44
4162
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
2
1271
by: | last post by:
I am looking for a easy way to trap an Exception that may occurr in any one of 30 child web controls to be trapped at the topmost parent WebUser control or Page Level. I have tried variations of...
19
3189
by: Diego F. | last post by:
I think I'll never come across that error. It happens when running code from a DLL that tries to write to disk. I added permissions in the project folder, the wwwroot and in IIS to NETWORK_SERVICE...
4
2229
by: Craig831 | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
0
2198
by: Gursharan | last post by:
Hi, I get this error after I did a load test on my website (500 constant user load in team system for 35 minutes). This error is logged after about 1 minute of load testing and is logged every...
0
1192
by: Ben Crinion | last post by:
Hi Im having a bit of a problem with an exception that doesnt seem to be bubbling up from a user control to its containing user control. The exception can occur on an event fired by a user...
1
2905
by: Efi Merdler | last post by:
Hi, I created a user control, but instead of handling exception in the user control level I prefer to handle them in the containing form. In the load event of the containing form I'm using:...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7347
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7416
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4732
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.