H
hardieca
Hi,
I've created an n-tier app where validation rules reside in the
business layer. When a webform is saved, a business object examines
its state, and if some property is invalid, throws a custom exception
(ValidationException)
The exception bubbles up to the UI where it gets trapped:
Private Sub Page_Error(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Error
Dim ctx As HttpContext = HttpContext.Current
Dim exception As Exception = ctx.Server.GetLastError()
If TypeOf (exception) Is ValidationException Then
Me.txtErrorMessages.Text = exception.message
ctx.Server.ClearError()
End If
End Sub
The exception is being successfully caught, but at the end of the
process I'm served with an empty page. What I would like to have
happen is the page reloads with all the form's information in addition
to a textbox being populated with the exception's message. I tried
using response.redirect(), but of course the textbox does not get
populated.
I'd rather not redirect the user to an error page, I want them to be
able to fix the validation errors on the form and continue on from
there. What's the best way to tackle this?
Regards,
Chris
I've created an n-tier app where validation rules reside in the
business layer. When a webform is saved, a business object examines
its state, and if some property is invalid, throws a custom exception
(ValidationException)
The exception bubbles up to the UI where it gets trapped:
Private Sub Page_Error(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Error
Dim ctx As HttpContext = HttpContext.Current
Dim exception As Exception = ctx.Server.GetLastError()
If TypeOf (exception) Is ValidationException Then
Me.txtErrorMessages.Text = exception.message
ctx.Server.ClearError()
End If
End Sub
The exception is being successfully caught, but at the end of the
process I'm served with an empty page. What I would like to have
happen is the page reloads with all the form's information in addition
to a textbox being populated with the exception's message. I tried
using response.redirect(), but of course the textbox does not get
populated.
I'd rather not redirect the user to an error page, I want them to be
able to fix the validation errors on the form and continue on from
there. What's the best way to tackle this?
Regards,
Chris