欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

file:///D:\w\login.aspx单文件处理

程序员文章站 2022-05-28 18:22:57
...
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
        Dim username As String = Me.Login1.UserName.Trim().ToLower()
        Dim userpass As String = Me.Login1.Password.Trim().ToLower()
        Dim sds As SqlDataSource = New SqlDataSource("Data Source=.;Initial Catalog=mydata;User ID=sa;Password=Abcdefg1", "select count(*) from t_user where username = @username and userpass = @userpass")
        sds.SelectParameters.Add("username", username)
        sds.SelectParameters.Add("userpass", userpass)
        Dim dv As System.Data.DataView = sds.Select(DataSourceSelectArguments.Empty)
        Dim b As Boolean = dv(0)(0)
        If b Then
            Session("username") = username
            Session("userpass") = userpass
            Response.Redirect("~/Default.aspx")
            Return
        End If
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Login ID="Login1" runat="server">
        </asp:Login>
    </div>
    </form>
</body>
</html>