throw exception back to the page

Discussion in 'ASP .Net Web Controls' started by SteveS, Oct 27, 2003.

  1. SteveS

    SteveS Guest

    Hello,

    I created a user control where there are several text boxes and a button.
    When the user clicks the button, I want to validate the data. When the the
    data is not valid, I would like to throw an exception. Is there a way to
    handle that exception on the main page? In other words, after the code
    throw new excpetion("you data is screwed up"), I would like to hit code on
    the main page to handle it.

    Thank you,

    SteveS
    SteveS, Oct 27, 2003
    #1
    1. Advertising

  2. SteveS

    Guest Guest

    Hi Steve,

    You can have your own Exception, just like the one used
    in the Catch statement.

    Try

    Catch ex as Exception

    End Try

    As the Message property of the Exception eobjkect is read-
    only,

    >-----Original Message-----
    >Hello,
    >
    >I created a user control where there are several text

    boxes and a button.
    >When the user clicks the button, I want to validate the

    data. When the the
    >data is not valid, I would like to throw an exception.

    Is there a way to
    >handle that exception on the main page? In other words,

    after the code
    >throw new excpetion("you data is screwed up"), I would

    like to hit code on
    >the main page to handle it.
    >
    >Thank you,
    >
    >SteveS
    >
    >
    >
    >.
    >
    Guest, Oct 28, 2003
    #2
    1. Advertising

  3. SteveS

    Guest Guest

    Sorry Steve,


    Hit Send (enter) by mistake !)

    Here is how :

    -----------------------

    Dim oExcep as Exception

    oExcep = New Exception("you data is screwed up")

    Throw oExcep

    -----------------------

    Hope this helps !

    Ben


    >-----Original Message-----
    >Hello,
    >
    >I created a user control where there are several text

    boxes and a button.
    >When the user clicks the button, I want to validate the

    data. When the the
    >data is not valid, I would like to throw an exception.

    Is there a way to
    >handle that exception on the main page? In other words,

    after the code
    >throw new excpetion("you data is screwed up"), I would

    like to hit code on
    >the main page to handle it.
    >
    >Thank you,
    >
    >SteveS
    >
    >
    >
    >.
    >
    Guest, Oct 28, 2003
    #3
    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. Kerri
    Replies:
    2
    Views:
    12,993
    Kevin Spencer
    Oct 27, 2003
  2. Guest
    Replies:
    1
    Views:
    1,199
    Alvin Bruney [MVP]
    Mar 2, 2004
  3. z. f.

    throw exception in the finalize

    z. f., Jul 5, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    422
    avnrao
    Jul 5, 2004
  4. Replies:
    15
    Views:
    7,482
    Roedy Green
    Sep 8, 2005
  5. Emanuele D'Arrigo

    To throw or to throw not?

    Emanuele D'Arrigo, Nov 14, 2008, in forum: Python
    Replies:
    6
    Views:
    309
    Emanuele D'Arrigo
    Nov 15, 2008
Loading...

Share This Page