开。。。。开玩笑啊,20分,要了多少东西。。。
以下是login.aspx.cs页面
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 _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
string username = Login1.UserName;
string pwd = Login1.Password;
string strSQL = "select LoginID from usertable where LoginID='" + username + "'";
if (ReDataSet(strSQL).Tables[0].Rows.Count = 0)
{
Response.Write("<script>alert('<font color=red>不存在的用户名</font>')");
}
else
{
string strSQL = "select PassWord from usertable where LoginID='" + username + "'";
if (ReDataSet(strSQL).Tables[0].Rows.Count = 0)
{
Response.Write("<script>alert('<font color=red>密码错误</font>')");
}
else
{
Response.Redirect("../first.aspx");
}
}
}
}
以下是login.aspx页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Login ID="Login1" runat="server" OnAuthenticate="Login1_Authenticate" FailureText="">
</asp:Login>
</div>
</form>
</body>
</html>
这个是网页的,不知道你是网页还是程序,不过基本差不多,换汤不换药,看看吧本回答被提问者采纳