Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Urgent User Control

Reply
Thread Tools

Urgent User Control

 
 
Prince Mathew
Guest
Posts: n/a
 
      04-07-2005
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


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      04-07-2005
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" <> wrote in message
news:...
> 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
>
>



 
Reply With Quote
 
 
 
 
Prince Mathew
Guest
Posts: n/a
 
      04-07-2005
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" <> wrote in message
news:...
> 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" <> wrote in message
> news:...
>> 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
>>
>>

>
>



 
Reply With Quote
 
Prodip Saha
Guest
Posts: n/a
 
      04-07-2005
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" <> wrote in message news:...
> 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" <> wrote in message
> news:...
> > 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" <> wrote in message
> > news:...
> >> 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
> >>
> >>

> >
> >

>
>

 
Reply With Quote
 
Prince Mathew
Guest
Posts: n/a
 
      04-07-2005
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" <> wrote in message news:...
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" <> wrote in message news:...
> 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" <> wrote in message
> news:...
> > 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" <> wrote in message
> > news:...
> >> 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
> >>
> >>

> >
> >

>
>

 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      04-07-2005
> 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" <> wrote in message
news:...
> 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" <> wrote in message
> news:...
>> 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" <> wrote in message
>> news:...
>>> 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
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Prince Mathew
Guest
Posts: n/a
 
      04-07-2005
Kevin,
Can you answer my question? Or are you still not clear about the question???

"Kevin Spencer" <> wrote in message
news:...
>> 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" <> wrote in message
> news:...
>> 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" <> wrote in message
>> news:...
>>> 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" <> wrote in message
>>> news:...
>>>> 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
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Prodip Saha
Guest
Posts: n/a
 
      04-07-2005
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" <> wrote in message news:...
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" <> wrote in message news:...
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" <> wrote in message news:...
> 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" <> wrote in message
> news:...
> > 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" <> wrote in message
> > news:...
> >> 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
> >>
> >>

> >
> >

>
>

 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      04-07-2005
> 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" <> wrote in message
news:...
> Kevin,
> Can you answer my question? Or are you still not clear about the
> question???
>
> "Kevin Spencer" <> wrote in message
> news:...
>>> 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" <> wrote in message
>> news:...
>>> 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" <> wrote in message
>>> news:...
>>>> 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" <> wrote in message
>>>> news:...
>>>>> 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
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
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
User Control to Control Other User Control Jonathan Wood ASP .Net 4 02-02-2010 03:41 PM
persisting changes to a control outside a user control from the user control? Mad Scientist Jr ASP .Net 0 03-22-2006 08:02 AM
Event not firing for user control inside user control vatech1993 ASP .Net 4 12-11-2004 02:51 PM
returning the selected value of a listbox control inside a user control - please urgent! Moe Sizlak ASP .Net 4 07-20-2004 10:11 PM
Manipulating a User Control from another User Control Tom Rowton ASP .Net 2 08-01-2003 08:18 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57