asp.net 哪里错了?

GUOCONG08 GUOCONG08 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我用vs2010做asp.net 写以下代码
后

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;



namespace zty
{
public partial class Login : System.Web.UI.Page
{
SqlConnection Conn = null;
SqlCommand Comm = null;
SqlDataAdapter Myadapter = null;
DataSet Myds = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Session.Clear();
}
dl.Attributes.Add("onmouseover", "this.src='../images/bn_2.gif'");
dl.Attributes.Add("onmouseout", "this.src='../images/bn_1.gif'");
}

protected void dl_Click(object sender, ImageClickEventArgs e)
{
Conn = new SqlConnection((string)Application["sql_zty"]);
Conn.Open();
string xm = Projectname.Text.ToString().Trim();
string zh = Username.Text.ToString().Trim();
string mm = password.Text.ToString().Trim();
string sql_str = "";
if (zh == "")
{
Response.Write("<script>alert('请输入登陆帐号!');history.back();</script>");
Response.End();
}
else if (mm == "")
{
Response.Write("<script>alert('请输入登陆密码!');history.back();</script>");
Response.End();
}
else if (xm != "")
{
sql_str = "select * from Login where Account='" + zh + "' and Name='" + xm + "'";
Myadapter = new SqlDataAdapter(sql_str, Conn);
Myds = new DataSet();
Myadapter.Fill(Myds, "Login");
if (Myds.Tables["Login"].Rows.Count <= 0)
{
Response.Write("<script>alert('您还没有注册帐号或未参加该项目!');history.back();</script>");
}
else
{
string pass = Myds.Tables["Login"].Rows[0]["password"].ToString().Trim();
string projectstrat = Myds.Tables["Login"].Rows[0]["status"].ToString().Trim();
string userstrat = Myds.Tables["Login"].Rows[0]["userstatus"].ToString().Trim();
string Project = Myds.Tables["Login"].Rows[0]["Projectstatus"].ToString().Trim();
if (pass != mm)
{
Response.Write("<script>alert('用户密码输入错误!');history.back();</script>");
Response.End();
}
else if (projectstrat == "0")
{
Response.Write("<script>alert('客服还未审核该项目!');history.back();</script>");
Response.End();
}
else if (projectstrat == "2")
{
string projectReason = Myds.Tables["Login"].Rows[0]["Reason"].ToString().Trim();
ClientScript.RegisterStartupScript(this.GetType(), "该项目的审核未被通过!", "<script language='javascript' >alert('因" + projectReason + "的原因,网站管理人员未通过该项目的审核!');</script>");
}
else if (userstrat == "0")
{
Response.Write("<script>alert('您加入该项目的申请还未被项目创建人审核!');history.back();</script>");
Response.End();
}
else if (userstrat == "2")
{
string userReason = Myds.Tables["Login"].Rows[0]["userReason"].ToString().Trim();
ClientScript.RegisterStartupScript(this.GetType(), "您加入该项目的审核未被通过!", "<script language='javascript' >alert('因" + userReason + "的原因,项目创建者未通过该项目的审核!');</script>");
}
else if (userstrat == "3")
{
string stopReason = Myds.Tables["Login"].Rows[0]["stop"].ToString().Trim();
string stoptime = Myds.Tables["Login"].Rows[0]["Enddate"].ToString().Trim();
ClientScript.RegisterStartupScript(this.GetType(), "您已经被踢出该项目!", "<script language='javascript' >alert('因" + stopReason + "的原因,您已经于" + stoptime + "被项目创建者踢出该项目!');</script>");
}
else if (userstrat == "4")
{
string endtime = Myds.Tables["Login"].Rows[0]["Enddate"].ToString().Trim();
ClientScript.RegisterStartupScript(this.GetType(), "您已经退出该项目!", "<script language='javascript' >alert(您已经于" + endtime + "退出该项目!');</script>");
}
else if (Project == "1")
{
System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "友情提示!", "confirm('该项目已结束,您确认要进入该项目吗?')", true);
string name = Myds.Tables["Login"].Rows[0]["username"].ToString().Trim();
string userid = Myds.Tables["Login"].Rows[0]["userid"].ToString().Trim();
string projectname = Myds.Tables["Login"].Rows[0]["name"].ToString().Trim();
string projectid = Myds.Tables["Login"].Rows[0]["userid"].ToString().Trim();
string adds = Myds.Tables["Login"].Rows[0]["adds"].ToString().Trim();
Session["username"] = name;
Session["userid"] = userid;
Session["name"] = projectname;
Session["userid"] = projectid;
Session["adds"] = adds;
Response.Redirect("Manage/index.aspx");
}
else
{
string name = Myds.Tables["Login"].Rows[0]["username"].ToString().Trim();
string userid = Myds.Tables["Login"].Rows[0]["userid"].ToString().Trim();
string projectname = Myds.Tables["Login"].Rows[0]["name"].ToString().Trim();
string projectid = Myds.Tables["Login"].Rows[0]["userid"].ToString().Trim();
string adds = Myds.Tables["Login"].Rows[0]["adds"].ToString().Trim();
Session["username"] = name;
Session["userid"] = userid;
Session["name"] = projectname;
Session["userid"] = projectid;
Session["adds"] = adds;
Response.Redirect("Manage/index.aspx");
}
}
}
else
{
wxm.Visible = true;
}
}

protected void xm_yes_Click(object sender, EventArgs e)
{
wxm.Visible = false;
Conn = new SqlConnection((string)Application["sql_zty"]);
Conn.Open();
string xm = Projectname.Text.ToString().Trim();
string zh = Username.Text.ToString().Trim();
string mm = password.Text.ToString().Trim();
string sql_str = "";
sql_str = "select * from Users where Account='" + zh + "'";
Myadapter = new SqlDataAdapter(sql_str, Conn);
Myds = new DataSet();
Myadapter.Fill(Myds, "Users");
if (Myds.Tables["Users"].Rows.Count <= 0)
{
Response.Write("<script>alert('当前用户不存在!');history.back();</script>");
}
else
{
string upass = Myds.Tables["users"].Rows[0]["password"].ToString().Trim();
if (upass != mm)
{
Response.Write("<script>alert('用户密码输入错误!');history.back();</script>");
Response.End();
}
else
{
string name = Myds.Tables["users"].Rows[0]["name"].ToString().Trim();
string userid = Myds.Tables["users"].Rows[0]["id"].ToString().Trim();
Session["name"] = name;
Session["userid"] = userid;
Response.Redirect("Manage/index.aspx");
}

}
Comm.Dispose();
Conn.Close();
Conn.Dispose();
}

protected void xm_no_Click(object sender, EventArgs e)
{
wxm.Visible = false;
}
}
}


我要达到的目的是框xm里有没有内容都可以登入 但会跳出个div提示框是否确定xm为空 是的话就执行下面的是的话就登陆 否的话就div提示框隐藏 如果xm不为空则直接登陆

但现在实际情况是这样的:我xm框里不输入东西 在zh和mm框里输上了,点登陆 跳出刚才那个div框 按框里的否的话是正常的,按是的话 他跳出密码错误提示(其实密码是正确的),密码错误提示上的确定点了以后 跳回登陆窗口 发现div提示框没隐藏(我明明写过隐藏的),然后在密码框里填入密码,再按div提示框上的是才可以正常登陆
经过证实那个跳出的密码错误提示是那个叫xm_yes的按钮里的
...全文
评论 7
收藏 已收藏
分享
返回顶部
GUOCONG08
.NET社区 62,272 成员 668,968 内容