I get an error, but I can't see it because you have your custom error setting in your web config to something other than 'Off' If you set it to Off, then we can see the errors and get them back to you.
Originally posted by hellswraith I get an error, but I can't see it because you have your custom error setting in your web config to something other than 'Off' If you set it to Off, then we can see the errors and get them back to you.
I will do it staight away...Please try again and let me know...
Originally posted by DevGrp Yes thats what he means. Also, you should use the error provider instead of using all those if else tests.
OK I will use SUB and change it when I go home...
I try to used those RequiredValidator but the moment I hit the SUBMIT button all the fields were cleared and an EMPTY record was inserted into database...Note that the values weren't NULL so it went allright...
So I was pissed off and removed all of them and then used that long IF ELSE END IF thingy...
Private Function ValidateEntry(ByVal s1 As String, _
ByVal s2 As String, _
ByVal s3 As String, _
ByVal s4 As String, _
ByVal s5 As String, _
ByVal s6 As String, _
ByVal s7 As String, _
ByVal s8 As String, _
ByVal s9 As String, _
ByVal s10 As String, _
ByVal s11 As String) As Boolean
If s1 = "" Then
lblError.Text = "*UserName is REQUIRED."
ValidateEntry = False
Else
If s2 = "" Then
lblError.Text = "*Password is REQUIRED."
ValidateEntry = False
Else
If s3 = "" Then
lblError.Text = "*FirstName is REQUIRED."
ValidateEntry = False
Else
If s4 = "" Then
lblError.Text = "*LastName is REQUIRED."
ValidateEntry = False
Else
If s5 = "" Then
lblError.Text = "*Address is REQUIRED."
ValidateEntry = False
Else
If s6 = "" Then
lblError.Text = "*Suburb is REQUIRED."
ValidateEntry = False
Else
If s7 = "" Then
lblError.Text = "*City is REQUIRED."
ValidateEntry = False
Else
If s8 = "" Then
lblError.Text = "*State is REQUIRED."
ValidateEntry = False
Else
If s9 = "" Then
lblError.Text = "*PostCode is REQUIRED."
ValidateEntry = False
Else
If s10 = "" Then
lblError.Text = "*Country is REQUIRED."
ValidateEntry = False
Else
If s11 = "" Then
lblError.Text = "*EMail is REQUIRED."
ValidateEntry = False
Else
If Len(s5) > 100 Then
lblError.Text = "*Address can not be more than 100 characters."
ValidateEntry = False
Else
ValidateEntry = True
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Function
or:
Code:
Private Function ValidateEntry(ByVal s1 As String, _
ByVal s2 As String, _
ByVal s3 As String, _
ByVal s4 As String, _
ByVal s5 As String, _
ByVal s6 As String, _
ByVal s7 As String, _
ByVal s8 As String, _
ByVal s9 As String, _
ByVal s10 As String, _
ByVal s11 As String) As Boolean
If s1 = "" Then
lblError.Text = "*UserName is REQUIRED."
Return False
End If
If s2 = "" Then
lblError.Text = "*Password is REQUIRED."
Return False
End If
If s3 = "" Then
lblError.Text = "*FirstName is REQUIRED."
Return False
End If
If s4 = "" Then
lblError.Text = "*LastName is REQUIRED."
Return False
End If
If s5 = "" Then
lblError.Text = "*Address is REQUIRED."
Return False
End If
If s6 = "" Then
lblError.Text = "*Suburb is REQUIRED."
Return False
End If
If s7 = "" Then
lblError.Text = "*City is REQUIRED."
Return False
End If
If s8 = "" Then
lblError.Text = "*State is REQUIRED."
Return False
End If
If s9 = "" Then
lblError.Text = "*PostCode is REQUIRED."
Return False
End If
If s10 = "" Then
lblError.Text = "*Country is REQUIRED."
Return False
End If
If s11 = "" Then
lblError.Text = "*EMail is REQUIRED."
Return False
End If
If Len(s5) > 100 Then
lblError.Text = "*Address can not be more than 100 characters."
Return False
End If
Return True
End Function
If you are going to do it that way, at least make it easier to look through.
Private Function ValidateEntry(ByVal s1 As String, _
ByVal s2 As String, _
ByVal s3 As String, _
ByVal s4 As String, _
ByVal s5 As String, _
ByVal s6 As String, _
ByVal s7 As String, _
ByVal s8 As String, _
ByVal s9 As String, _
ByVal s10 As String, _
ByVal s11 As String) As Boolean
If s1 = "" Then
lblError.Text = "*UserName is REQUIRED."
ValidateEntry = False
Else
If s2 = "" Then
lblError.Text = "*Password is REQUIRED."
ValidateEntry = False
Else
If s3 = "" Then
lblError.Text = "*FirstName is REQUIRED."
ValidateEntry = False
Else
If s4 = "" Then
lblError.Text = "*LastName is REQUIRED."
ValidateEntry = False
Else
If s5 = "" Then
lblError.Text = "*Address is REQUIRED."
ValidateEntry = False
Else
If s6 = "" Then
lblError.Text = "*Suburb is REQUIRED."
ValidateEntry = False
Else
If s7 = "" Then
lblError.Text = "*City is REQUIRED."
ValidateEntry = False
Else
If s8 = "" Then
lblError.Text = "*State is REQUIRED."
ValidateEntry = False
Else
If s9 = "" Then
lblError.Text = "*PostCode is REQUIRED."
ValidateEntry = False
Else
If s10 = "" Then
lblError.Text = "*Country is REQUIRED."
ValidateEntry = False
Else
If s11 = "" Then
lblError.Text = "*EMail is REQUIRED."
ValidateEntry = False
Else
If Len(s5) > 100 Then
lblError.Text = "*Address can not be more than 100 characters."
ValidateEntry = False
Else
ValidateEntry = True
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Function
or:
Code:
Private Function ValidateEntry(ByVal s1 As String, _
ByVal s2 As String, _
ByVal s3 As String, _
ByVal s4 As String, _
ByVal s5 As String, _
ByVal s6 As String, _
ByVal s7 As String, _
ByVal s8 As String, _
ByVal s9 As String, _
ByVal s10 As String, _
ByVal s11 As String) As Boolean
If s1 = "" Then
lblError.Text = "*UserName is REQUIRED."
Return False
End If
If s2 = "" Then
lblError.Text = "*Password is REQUIRED."
Return False
End If
If s3 = "" Then
lblError.Text = "*FirstName is REQUIRED."
Return False
End If
If s4 = "" Then
lblError.Text = "*LastName is REQUIRED."
Return False
End If
If s5 = "" Then
lblError.Text = "*Address is REQUIRED."
Return False
End If
If s6 = "" Then
lblError.Text = "*Suburb is REQUIRED."
Return False
End If
If s7 = "" Then
lblError.Text = "*City is REQUIRED."
Return False
End If
If s8 = "" Then
lblError.Text = "*State is REQUIRED."
Return False
End If
If s9 = "" Then
lblError.Text = "*PostCode is REQUIRED."
Return False
End If
If s10 = "" Then
lblError.Text = "*Country is REQUIRED."
Return False
End If
If s11 = "" Then
lblError.Text = "*EMail is REQUIRED."
Return False
End If
If Len(s5) > 100 Then
lblError.Text = "*Address can not be more than 100 characters."
Return False
End If
Return True
End Function
If you are going to do it that way, at least make it easier to look through.
By your method is two fields are empty then it will overwrite the previous message in the lable...
But as far as I understand there is no problem doing the method I am using right now...