This is probably going to end up as a stupid question, but countless research has offered me no results.
I know there are different types of errors I want to check for, and when I should be throwing an exception for “exceptional” errors, and that I should create validating functions for input and other checks.
My problem is, how do I send an error back to a page when the data entered fails in a separate class?
For Example:
- User input entered in Page1.aspx, click calls Submit() in Class.vb
- Class.vb finds that input is invalid
- How do I update Page1.aspx label to say “Hey, that is not right”.
I can do it on inline page, no problem, its passing it through a separate class that’s causing me issues… Maybe I’m not even thinking of this correctly.
Any points in the right direction would be of huge help.
Thanks for the help in advance.
The simplest solution is to have Submit() return a boolean indicating whether there was an error or not:
It is a good practice to put your class in charge of its own errors, in which case you would expose an error message property:
The Submit function would look something like this: