⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 login.aspx.vb

📁 Visual Basic.NET控件时尚编程百例
💻 VB
字号:
Public Class Login
    Inherits System.Web.UI.Page
    Protected WithEvents txtUserName As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtPassword As System.Web.UI.WebControls.TextBox
    Protected WithEvents chkPersist As System.Web.UI.WebControls.CheckBox
    Protected WithEvents btnLogin As System.Web.UI.WebControls.Button
    Protected WithEvents hdnReturnUrl As System.Web.UI.HtmlControls.HtmlInputHidden
    Protected WithEvents lnkNewAccount As System.Web.UI.WebControls.HyperLink
    Protected WithEvents lblMessage As System.Web.UI.WebControls.Label

#Region " Web 窗体设计器生成的代码 "

    '该调用是 Web 窗体设计器所必需的。
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
        '不要使用代码编辑器修改它。
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '在此处放置初始化页的用户代码
        If (Request.QueryString("hdnReturnUrl") <> "") Then
            hdnReturnUrl.Value = Request.QueryString("ReturnUrl")
            lnkNewAccount.NavigateUrl = "NewAccount.aspx?ReturnUrl=" & hdnReturnUrl.Value
        End If
    End Sub

    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        If Page.IsValid = True Then
            Dim strCustomerID As String
            Dim myShopper As New StoreCommon.Services.ShoppingCart()
            Dim tempCartId As String = myShopper.GetCartID
            Dim AccountSystem As New StoreCommon.Services.DBCustomer()
            strCustomerID = AccountSystem.AuthenticateCustomer(txtUserName.Text, txtPassword.Text).ToString
            Response.Write(strCustomerID)
            If strCustomerID <> "0" Then
                myShopper.Migrate(tempCartId, strCustomerID)
                Dim objCustomer As StoreCommon.Services.Customer
                objCustomer = AccountSystem.GetCustomerDetails(strCustomerID)
                Response.Cookies("CustomerName").Value = objCustomer.CustomerName
                If chkPersist.Checked = True Then
                    '表示过一个月后将过期
                    Response.Cookies("CustomerName").Expires = DateTime.Now.AddMonths(1)
                    '将页面重新定向为记住密码的状态
                    System.Web.Security.FormsAuthentication.RedirectFromLoginPage(strCustomerID, chkPersist.Checked)
                End If
                Response.Redirect("default.aspx")
            End If
        Else
            lblMessage.Text = "登录失败,请重新输入您的 Email 地址和密码。"
        End If

    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -