📄 webusercontrol.ascx.cs
字号:
using System;
using System.Data;
using System.Configuration;
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;
using System.Data.SqlClient;
public partial class WebUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public int checkLogin(string loginName, string loginPwd)
{
SqlConnection con = new SqlConnection("Server=(local);database=mrdb;Uid=sa;Pwd=");
SqlCommand myCommand = new SqlCommand("select count(*) from UserData where loginName=@loginName and loginPwd=@loginPwd", con);
myCommand.Parameters.Add(new SqlParameter("@loginName", SqlDbType.NVarChar, 20));
myCommand.Parameters["@loginName"].Value = loginName;
myCommand.Parameters.Add(new SqlParameter("@loginPwd", SqlDbType.NVarChar, 20));
myCommand.Parameters["@loginPwd"].Value = loginPwd;
myCommand.Connection.Open();
int i = (int)myCommand.ExecuteScalar();
myCommand.Connection.Close();
return i;
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
int i = this.checkLogin(txtName.Text, txtPwd.Text);
if (i > 0)
{
if (txtCheckCode.Text == Session["CheckCode"].ToString())
{
Response.Write("<script>alert('登录成功!!!')</script>");
}
else
{
Response.Write("<script>alert('验证码输入错误!!!')</script>");
}
}
else
{
Response.Write("<script>alert('用户名称或密码错误!!!')</script>");
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
txtName.Text = "";
txtPwd.Text = "";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -