Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (70.66 KB, 2 trang )
Code đăng nhập ASP.NET bằng VB.net
(Thứ Ba, 29/12/2009-11:00 AM)
Giao diện cùng code đăng nhập ASP.NET bằng VB.net.
Còn dưới đây là code:
quote:
Imports System.Data
Imports System.Data.SqlClient
Partial Class Dangnhap
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session.Item("Email") <> "" Then
Response.Redirect("~/DiaChiThanhToan.aspx")
End If
End Sub
Private Function ValidateUser(ByVal username As String, ByVal password As String)
Dim cn As SqlConnection = DBUtil.GetConnection
Dim cmd As New SqlCommand("Select Count(*) From KhachHang Where Email='" & userName & "'
AND Matkhau='" & password & "'", cn)
Dim Count As Integer = cmd.ExecuteScalar
Return Count <> 0
End Function
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
If ValidateUser(Login1.UserName, Login1.Password) Then
Session.Item("Email") = Login1.UserName
Response.Redirect("~/DiaChiThanhToan.aspx")
End If
End Sub
End Class
Imports System.Data