I have created a simple login page using loginview
login.aspx
Code:
<asp:LoginView ID="LoginView1" runat="server">   
     <AnonymousTemplate>  
       <asp:Login ID="loginsys" runat="server" UserNameLabelText="Username:" OnAuthenticate="loginsys_Authenticate" />  
       <asp:Label ID="lblErrMsg" runat="server" ForeColor="Red" />  
     </AnonymousTemplate>  
     <LoggedInTemplate>  
         Hello,<asp:LoginName ID="LoginName1" runat="server" />  
         <br />  
         <asp:LoginStatus ID="LoginStatus1" runat="server" LoginText="" LogoutText="Logout" />  
     </LoggedInTemplate>  
 </asp:LoginView>
login.aspx.vb
Code:
 Dim loginsys As WebControls.Login = Me.LoginView1.FindControl("loginsys")
    Dim lblErrMsg As Label = Me.LoginView1.FindControl("lblErrMsg")

    Protected Sub loginsys_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs)
        Try

            If ChkLogin(loginsys.UserName, loginsys.Password) Then
                FormsAuthentication.RedirectFromLoginPage(loginsys.UserName, loginsys.RememberMeSet)
            Else
                Throw New Exception("Login Failed")
            End If
        Catch ex As Exception
            lblErrMsg.Text = ex.Message
        End Try


    End Sub

    Public Function ChkLogin(ByVal UserName As String, ByVal UserPassword As String) As Boolean
        Dim conn As New SqlConnection
        Dim cmmd As New SqlCommand

        Dim pmtUserName As New SqlParameter
        Dim pmtUserPassword As New SqlParameter
        Dim strSQL As String
        Dim dr As SqlDataReader

        Try

            conn = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)

            conn.Open()
            strSQL = "SELECT * FROM tbl_user WHERE login = @login and pwd = @pwd"
            cmmd.Connection = conn
            cmmd.CommandText = strSQL

            pmtUserName.ParameterName = "@login"
            pmtUserName.Value = UserName
            pmtUserPassword.ParameterName = "@pwd"
            pmtUserPassword.Value = UserPassword

            cmmd.Parameters.Add(pmtUserName)
            cmmd.Parameters.Add(pmtUserPassword)

            dr = cmmd.ExecuteReader()

            If dr.Read Then
                ChkLogin = True
            Else

                Throw New Exception("Login Fails!!")
            End If

        Catch ex As Exception
            ChkLogin = False
            lblErrMsg.Text = ex.Message
        Finally

            pmtUserName = Nothing
            pmtUserPassword = Nothing

            dr = Nothing
            cmmd = Nothing
            conn = Nothing
        End Try

    End Function
However, i got the error message once start up the page

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

I have no ideas what kind of error it is since i don't find any problems in the code.

Could anybody advice, please?

Thank you