General information
Title:
Newbie - customvalidator
Dear All,
I am very new to ASP.NET, I am trying to create my 1st login page with customvalidator.. but it does not work.. I meant customvalidator not showing the message when user failed to login..
I need advise..
TIA & Regards
Teddy
Private Sub BtnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLogin.Click
CustomValidator1.Validate()
End Sub
Private Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
' Define ADO.NET Objects
Dim SQLSelect As String = "SELECT USERID, PASSWORD FROM USERS WHERE USERID = '" & txtUserID.Text & "' AND PASSWORD = '" & txtPassword.Text & "'"
Dim Cmd As New OleDbCommand(SQLSelect, Conn)
Try
Conn.Open()
Reader = Cmd.ExecuteReader()
Reader.Read()
If txtUserID.Text = Reader("UserId") And txtPassword.Text = Reader("Password") Then
'CustomValidator1.ErrorMessage = "Succeed!"
Else
CustomValidator1.ErrorMessage = "Invalid Credential"
End If
Reader.Close()
Catch err As Exception
CustomValidator1.ErrorMessage = err.Message
Finally
If Not Conn Is Nothing Then
Conn.Close()
End If
End Try
End Sub
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only