quote: Protected Sub Page_LoadByVal sender As Object, ByVal e As System.EventArgs Handles Me.Load If Session.Item"Email" "" Then Response.Redirect"~/DiaChiThanhToan.aspx" Private F
Trang 1Code đă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.
quote:
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")
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)
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")
Trang 2End Sub
End Class
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