急求.NET 后台登陆源码(c#语言),包括.aspx和.cs文件
表management中的用户名为manageid密码为managepwd界面输入框id为txtname和txtpwd急求我会追加分的...
表management中的用户名为manageid 密码为managepwd
界面输入框id为txtname和txtpwd
急求
我会追加分的 展开
界面输入框id为txtname和txtpwd
急求
我会追加分的 展开
3个回答
展开全部
.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test11.aspx.cs" Inherits="test11" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<style type="text/css">
.style1
{
width: 73px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div align="center">
<table width="220px" style="align:center">
<tr>
<td class="style1">
<span lang="zh-cn">用户名:</span></td>
<td>
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
<span lang="zh-cn">密码:</span></td>
<td>
<asp:TextBox ID="txtpwd" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="login" runat="server" Text="登陆" onclick="login_Click" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class test11 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void login_Click(object sender, EventArgs e)
{
string str = "server=(local);database=数据库名;user id=用户名;Password=密码;Max Pool Size=5000;";
SqlConnection myConn=new SqlConnection(str);
string myLoingID = this.txtname.Text.Trim().ToString();
string myPass = this.txtpwd.Text.Trim().ToString();
if (myLoingID == "")
{
Response.Write("<script>alert('请输入账号!');history.back();</script>");
this.txtname.Focus();
}
else if (myPass == "")
{
Response.Write("<script>alert('请输入密码!');history.back();</script>");
this.txtpwd.Focus();
}
else if (myLoingID != "" && myPass != "")
{
string Sqlstr = "select * from management where manageid =@loginname and managepwd=@loginpwd";
SqlDataAdapter sqldap = new SqlDataAdapter(Sqlstr, myConn);
sqldap.SelectCommand.Parameters.Add(new SqlParameter("@loginname", SqlDbType.Char, 10));
sqldap.SelectCommand.Parameters["@loginname"].Value = myLoingID;
sqldap.SelectCommand.Parameters.Add(new SqlParameter("@loginpwd", SqlDbType.VarChar, 80));
sqldap.SelectCommand.Parameters["@loginpwd"].Value = myPass;
DataSet ds = new DataSet();
sqldap.Fill(ds);
myConn.Close();
if (ds.Tables[0].Rows.Count > 0)
{
Response.Write("<script>window.parent.location.replace('0000_index.aspx');</script>");
}
else
{
Response.Write("<script>alert('用户名或密码错误!');history.back();</script>");
}
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test11.aspx.cs" Inherits="test11" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<style type="text/css">
.style1
{
width: 73px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div align="center">
<table width="220px" style="align:center">
<tr>
<td class="style1">
<span lang="zh-cn">用户名:</span></td>
<td>
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
<span lang="zh-cn">密码:</span></td>
<td>
<asp:TextBox ID="txtpwd" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="login" runat="server" Text="登陆" onclick="login_Click" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class test11 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void login_Click(object sender, EventArgs e)
{
string str = "server=(local);database=数据库名;user id=用户名;Password=密码;Max Pool Size=5000;";
SqlConnection myConn=new SqlConnection(str);
string myLoingID = this.txtname.Text.Trim().ToString();
string myPass = this.txtpwd.Text.Trim().ToString();
if (myLoingID == "")
{
Response.Write("<script>alert('请输入账号!');history.back();</script>");
this.txtname.Focus();
}
else if (myPass == "")
{
Response.Write("<script>alert('请输入密码!');history.back();</script>");
this.txtpwd.Focus();
}
else if (myLoingID != "" && myPass != "")
{
string Sqlstr = "select * from management where manageid =@loginname and managepwd=@loginpwd";
SqlDataAdapter sqldap = new SqlDataAdapter(Sqlstr, myConn);
sqldap.SelectCommand.Parameters.Add(new SqlParameter("@loginname", SqlDbType.Char, 10));
sqldap.SelectCommand.Parameters["@loginname"].Value = myLoingID;
sqldap.SelectCommand.Parameters.Add(new SqlParameter("@loginpwd", SqlDbType.VarChar, 80));
sqldap.SelectCommand.Parameters["@loginpwd"].Value = myPass;
DataSet ds = new DataSet();
sqldap.Fill(ds);
myConn.Close();
if (ds.Tables[0].Rows.Count > 0)
{
Response.Write("<script>window.parent.location.replace('0000_index.aspx');</script>");
}
else
{
Response.Write("<script>alert('用户名或密码错误!');history.back();</script>");
}
}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-11-05
展开全部
动软代码生成器就可以生成这样的代码,并且动软系统框架也有现成这样的代码,你可以去看看哦
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询