Problem with Login Page

lorena

Centurion
Joined
Oct 23, 2003
Messages
134
Location
Phoenix, Arizona
I have a small asp.net app that loads a login page with two textboxes for username and password and a login button. Each textbox has a RequiredFieldvalidator and I use the Page.IsValid for the OnClick event of the Login button.
I also have two hyperlinks on the page so that users can go back to non-login pages.
My problem is that the RequiredFieldvalidator events fire when either hyperlink is clicked and keep the hyperlinks from allowing users to navigate off of the page.
<script language="VB" runat="server">
'Code for the login button
Sub Login_Click(Src As Object, E As EventArgs)
If Page.IsValid Then
Dim strUN as string = txtUN.text
Dim strPW as string = txtPwd.text
Dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & server.mappath("DB/sf.mdb") & ";"
Dim Conn as New OLEDBConnection(strConn)
Conn.Open()
Dim strSQL as string = "SELECT * FROM info WHERE un = '~' and pwd= 'Val1'"
strSQL = Replace(strSQL,"~", strUN)
strSQL = Replace(strSQL,"Val1", strPW)
Dim Cmd as New OLEDBCommand(strSQL,Conn)

'Create a datareader, connection object
Dim Dr as OLEDBDataReader = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

'Get the first row and check the password.
If Dr.Read() then
If Dr("Pwd").ToString = txtPwd.text and DR("UN").ToString=txtUN.text Then
FormsAuthentication.RedirectFromLoginPage(txtUN.Text, false)
Else
lblLoginMsg.text = "Invalid login attempt."
End If
Else
lblLoginMsg.text = "Login name or Password not found."
End If
Dr.Close
End If
End Sub
Sub tds_img_OnClick(Sender As Object, E As ImageClickEventArgs)
If not Page.IsValid then
FormsAuthentication.SignOut()
Response.Redirect ("http://www.homepage.com")
End If
End Sub
Sub sup_img_OnClick(Sender As Object, E As ImageClickEventArgs)
FormsAuthentication.SignOut()
Response.Redirect ("http://www.homepage.com/sup/welcome.htm")
End Sub
</script>
Is there someway to get around this? Some Page event that I am missing?
Thanks in advance for any help.
 
Back
Top