1. Trang chủ
  2. » Công Nghệ Thông Tin

Code đăng nhập ASP.NET bằng VB.net pdf

2 735 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 2
Dung lượng 46,5 KB

Nội dung

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 1

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.

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 2

End 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

Ngày đăng: 29/07/2014, 06:20

TỪ KHÓA LIÊN QUAN

w