Form validation and error messages

andycharger

Well-known member
Joined
Apr 2, 2003
Messages
152
Im my web application, I am using the <asp:requiredfieldvalidator> to write errors to my Screen in red for fields not filled in my login screen.

Can someone tell me how I can do a similar thing if the username or password are incorrect?
Currently, I am using a logon.aspx.vb form with the following code:
Code:
 Public Sub CreateMySqlDataReader(ByVal mySelectQuery As String, _
    ByVal myConnectionString As String)
        Dim myConnection As New SqlConnection(myConnectionString)
        Dim myCommand As New SqlCommand(mySelectQuery, myConnection)
        myCommand.Connection.Open()
        Dim strName As String
        Dim strError As String
        Dim myReader As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
        If myReader.Read() Then

            Dim ckCookie As New HttpCookie("UserCookie")
            Dim strUserID As String
            strUserID = myReader("UserID")

            ckCookie.Value = strUserID.ToString()


                Response.Redirect("WebForm1.aspx")
                FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, PersistCookie.Checked)


            Console.WriteLine(myReader.GetString(0))

        Else
            Response.write ( "Either your username or password were incorrect.")
        End If

        myReader.Close()
        myConnection.Close()

    End Sub

however, I have no control over where it appears on screen.

Can anyone suggest a better way?
 
Back
Top