S
Stephen Witter
I have the following example to catch more than one error. I am new
to error handling in .net so I am wondering if the following is an
exceptable approach:
Sub LinkButton1_Click(sender As Object, e As EventArgs)
Try
txtDate.text=("hi"/0)
Catch ex As Exception
if ex.GetType.ToString ="System.InvalidCastException" then
Response.write("You have entered an invalid date.")
else
Response.write("There was an error.")
end if
exit sub
End Try
End Sub
I am used to error handling in access where, using the err.number, you
could trap a specific error and return a message for that error. The
only reason I ask is because the above approach wasn't real obvious to
find at MSDN so I question whether I should be doing it this way. Any
suggestions are appreciated.
to error handling in .net so I am wondering if the following is an
exceptable approach:
Sub LinkButton1_Click(sender As Object, e As EventArgs)
Try
txtDate.text=("hi"/0)
Catch ex As Exception
if ex.GetType.ToString ="System.InvalidCastException" then
Response.write("You have entered an invalid date.")
else
Response.write("There was an error.")
end if
exit sub
End Try
End Sub
I am used to error handling in access where, using the err.number, you
could trap a specific error and return a message for that error. The
only reason I ask is because the above approach wasn't real obvious to
find at MSDN so I question whether I should be doing it this way. Any
suggestions are appreciated.