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

📄 logoncontrol.ascx.cs

📁 这是我做的第一个网络购书中心asp.net网站!
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class UserControl_logonControl : System.Web.UI.UserControl
{
    randomCode ran = new randomCode();
    UserInfo ui = new UserInfo();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            string sVaild = ran.RandomNum(4);
            labVaild.Text = sVaild;
            if (Session["UID"] != null)
            {
                tbLoading.Visible = true;
                tbRregister.Visible = false;
            }
        }

    }
    protected void btnRes_Click(object sender, EventArgs e)
    {
        Response.Redirect("Register.aspx");
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        
        if (txtVaild.Text == labVaild.Text)
        {
            labTip.Visible = false;
            if (ui.IsUserExist(txtUserID.Text.Trim(), txtBoxPaw.Text.Trim()))
            {
                DataSet ds = ui.returnUserInfo(txtUserID.Text.Trim(), txtBoxPaw.Text.Trim());
                Session["UID"] = ds.Tables[0].Rows[0][0].ToString();//是否需要转换
                Session["UserName"] = ds.Tables[0].Rows[0][1].ToString();
                Response.Redirect("index.aspx");

            }
            else
            {
                labVaild.Text = ran.RandomNum(4);
                Clear();
                ui.MessageBox(Page, "用户名或密码错误");
                
            }
        }
        else
        {
            labTip.Visible = true;
            labVaild.Text = ran.RandomNum(4);
            Clear();
        }
    }
    protected void Clear()
    {
        txtUserID.Text = "";
        txtBoxPaw.Text = "";
        txtVaild.Text = "";
    }
    protected void lnbExit_Click(object sender, EventArgs e)
    {
        Session["UID"] = null;
        Session["UserName"] = null;
        Response.Redirect("~/User/index.aspx");
    }
    protected void linkBottonReport_Click(object sender, EventArgs e)
    {

        Response.Redirect("~/User/OrderInfoReport.aspx");
    }

    protected void txtBoxPaw_TextChanged(object sender, EventArgs e)
    {
        ((TextBox)sender).Text += "*";
    }
   
}

⌨️ 快捷键说明

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