gromul
asked on
Getting Validation Summary info
Is there a way to extract error messages contained in ValidationSummary control?
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This answer gave me what I needed, but it actually gives the text of all the validators, whether they are valid or not.
I am loading a form from XML data and will automatically move to another page if there is no error. However, if there is an error, I have to save the errors. I refined the accepted answer so that I see only the validators where Isvalid = false.
Validate("UserInfo")
If Not IsValid Then
Dim RxErrors As String = ""
Dim vc As ValidatorCollection = Page.Validators
Dim Index As Integer
For Index = 0 To vc.Count - 1
If vc.Item(Index).IsValid = False Then
RxErrors += "<Error>" & (vc(Index).ErrorMessage) & "</Error>"
End If
Next
If RxErrors.Trim.Length > 0 Then
RxErrors = "<Errors>" & RxErrors & "</Errors>"
End If
End If
I am loading a form from XML data and will automatically move to another page if there is no error. However, if there is an error, I have to save the errors. I refined the accepted answer so that I see only the validators where Isvalid = false.
Validate("UserInfo")
If Not IsValid Then
Dim RxErrors As String = ""
Dim vc As ValidatorCollection = Page.Validators
Dim Index As Integer
For Index = 0 To vc.Count - 1
If vc.Item(Index).IsValid = False Then
RxErrors += "<Error>" & (vc(Index).ErrorMessage) & "</Error>"
End If
Next
If RxErrors.Trim.Length > 0 Then
RxErrors = "<Errors>" & RxErrors & "</Errors>"
End If
End If
ASKER