Urgent User Control

Discussion in 'ASP .Net' started by Prince Mathew, Apr 7, 2005.

  1. 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
     
    Prince Mathew, Apr 7, 2005
    #1
    1. Advertising

  2. 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
    >
    >
     
    Kevin Spencer, Apr 7, 2005
    #2
    1. Advertising

  3. 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
    >>
    >>

    >
    >
     
    Prince Mathew, Apr 7, 2005
    #3
  4. Prince Mathew

    Prodip Saha Guest

    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
    > >>
    > >>

    > >
    > >

    >
    >
     
    Prodip Saha, Apr 7, 2005
    #4
  5. 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
    > >>
    > >>

    > >
    > >

    >
    >
     
    Prince Mathew, Apr 7, 2005
    #5
  6. > 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
    >>>
    >>>

    >>
    >>

    >
    >
     
    Kevin Spencer, Apr 7, 2005
    #6
  7. 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
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    Prince Mathew, Apr 7, 2005
    #7
  8. Prince Mathew

    Prodip Saha Guest

    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
    > >>
    > >>

    > >
    > >

    >
    >
     
    Prodip Saha, Apr 7, 2005
    #8
  9. > 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
    >>>>>
    >>>>>
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    Kevin Spencer, Apr 7, 2005
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Moe Sizlak
    Replies:
    4
    Views:
    775
    Moe Sizlak
    Jul 20, 2004
  2. Mad Scientist Jr
    Replies:
    0
    Views:
    639
    Mad Scientist Jr
    Mar 22, 2006
  3. Sachin Jagtap

    URGENT !! QUEUE STL PROBLEM URGENT!!

    Sachin Jagtap, Apr 28, 2005, in forum: C++
    Replies:
    4
    Views:
    1,045
    Mark Stijnman
    Apr 29, 2005
  4. Jonathan Wood

    User Control to Control Other User Control

    Jonathan Wood, Jan 24, 2010, in forum: ASP .Net
    Replies:
    4
    Views:
    548
    Jonathan Wood
    Feb 2, 2010
  5. Rob
    Replies:
    3
    Views:
    437
Loading...

Share This Page