关于 vb.net 如何实现 点击网页登陆按钮 50
<tdonClick="javascript:setMD5Passwd();"onMouseOver="this.className=over"onMouseOut="t...
<td onClick="javascript:setMD5Passwd();" onMouseOver="this.className=over" onMouseOut="this.className=out" > </td>"
这是按钮的源代码, 该如何实现呢? 展开
这是按钮的源代码, 该如何实现呢? 展开
1个回答
展开全部
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "" || TextBox2.Text == "")
{
Response.Write("<script>alert('用户名或密码不能为空!')</script>"); //提示对话框
}
else
{
string ConStr = "server=(local);user id=sa;pwd=123456;database=userdb";
SqlConnection con = new SqlConnection(ConStr);
string SqlStr = "select * from mymember where sname = '" + TextBox1.Text + "' and spwd = '" + TextBox2.Text + "'"; //Select查询语句
SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con);
con.Open(); //打开连接
DataSet ds = new DataSet();
ada.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
Session["username"] = TextBox1.Text;
Response.Redirect("index.aspx");
}
else
{
Response.Write("<script>alert('用户名或密码错误,请重新登录!')</script>");
}
} //绑定GridView控件
}
{
if (TextBox1.Text == "" || TextBox2.Text == "")
{
Response.Write("<script>alert('用户名或密码不能为空!')</script>"); //提示对话框
}
else
{
string ConStr = "server=(local);user id=sa;pwd=123456;database=userdb";
SqlConnection con = new SqlConnection(ConStr);
string SqlStr = "select * from mymember where sname = '" + TextBox1.Text + "' and spwd = '" + TextBox2.Text + "'"; //Select查询语句
SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con);
con.Open(); //打开连接
DataSet ds = new DataSet();
ada.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
Session["username"] = TextBox1.Text;
Response.Redirect("index.aspx");
}
else
{
Response.Write("<script>alert('用户名或密码错误,请重新登录!')</script>");
}
} //绑定GridView控件
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询