Home > Net >  For help, whether to exist asp validation registered users how to do
For help, whether to exist asp validation registered users how to do

Time:11-28

using System;
Using System. The Data;
Using System. The Configuration;
using System.Collections;
Using System. The 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;
Using System. The Data. SqlClient.
Public partial class UserLogin: System. Web. UI. UserControl
{
The SqlHelper data=https://bbs.csdn.net/topics/new SqlHelper ();
Protected void Page_Load (object sender, EventArgs e)
{
if (! IsPostBack)
{
If (Session (" UserId ")==null)
{
Login1. Visible=false;
Login2. Visible=true;

}
The else
{
Label1. Text=Session (" UserName "). The ToString ();

Login1. Visible=true;
Login2. Visible=false;

}
}

}
Protected void LinkButton2_Click (object sender, EventArgs e)
{
Response. Redirect (" UserStReg. Aspx ");

}

Protected void Button4_Click (object sender, EventArgs e)
{
The Session. Abandon ();
The Session. The Clear ();
The Session (" UserId ")=null;
The Session (" UserName ")=null;
Response. Redirect (" Default. Aspx ");
}
Protected void Button1_Click (object sender, EventArgs e)
{
If (Session) [r]. "Roule" ToString ()=="buyer")
{
Response. Redirect (" UserHome. Aspx ");
}
The else
{
The Response. Redirect (" MaiJia/Default. Aspx ");

}
}
Protected void Button2_Click (object sender, EventArgs e)
{

If (DropDownList1 SelectedValue=https://bbs.csdn.net/topics/="buyer")
{
If (TxtUserName. Text=="" & amp; & TxtPassword. Text=="")
{
Alert. AlertAndRedirect (" no input account and password!" , "UserLogin. Aspx");
}
The else
{
SqlDataReader Dr;
Dr=data. GetDataReader (" select * from the Users where the UserName='" + TxtUserName. Text. The Trim () + "' and PWD='" + TxtPassword. Text. The Trim () + "' ");
If (Dr. Read ())
{
The Session (" UserId ")=Dr [r]. "id" ToString ();
The Session (" UserName ")=Dr [r]. "UserName" ToString ();
Session [" XingMing "]=Dr [r]. "XingMing" ToString ();

The Session/" Roule "=" buyers ";
Response. Redirect (" UserLogin. Aspx ");
}
The else
{
Alert. AlertAndRedirect (" account or password is wrong please log in again!" , "UserLogin. Aspx");
}
}
}
The else
{
If (TxtUserName. Text=="" & amp; & TxtPassword. Text=="")
{
Alert. AlertAndRedirect (" no input account and password!" , "UserLogin. Aspx");
}
The else
{
SqlDataReader Dr;
Dr=data. GetDataReader (" select * from ShangJia where LoginName='" + TxtUserName. Text. The Trim () + "' and LoginPwd='" + TxtPassword. Text. The Trim () + "' ");
If (Dr. Read ())
{
The Session (" UserId ")=Dr [r]. "id" ToString ();
Session (" UserName ")=Dr [r]. "LoginName" ToString ();
Session [" XingMing "]=Dr [r]. "the name" the ToString ();

The Session [" Roule "]="the seller";
Response. Redirect (" UserLogin. Aspx ");
}
The else
{
Alert. AlertAndRedirect (" account or password is wrong please log in again!" , "UserLogin. Aspx");
}
}

}
}
Protected void Button3_Click (object sender, EventArgs e)
{
Response. Redirect (" FindPwd. Aspx ");
}
}
  • Related