在线急等,asp.net问题

GUOCONG08 2011-01-20 03:42:21
我用vs2010做asp.net 代码如下:
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 == "")
{


System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "友情提示!", "confirm('您确定不登入项目吗?')", true);



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 pass = Myds.Tables["users"].Rows[0]["password"].ToString().Trim();
if (pass == mm)
{
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");
}
else
{
Response.Write("<script>alert('用户密码输入错误!');history.back();</script>");
Response.End();
}

}
Comm.Dispose();
Conn.Close();
Conn.Dispose();
}
else
{
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");
}
}
}
}
}
}


其他都正常 但当xm为空时跳过了提示框 System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "友情提示!", "confirm('您确定不登入项目吗?')", true);
怎么办?要怎么改?
...全文
117 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
GUOCONG08 2011-01-20
  • 打赏
  • 举报
回复
还有忘说了 这个跳出来的提示框有两个选项 选不同选项 执行的代码不同
GUOCONG08 2011-01-20
  • 打赏
  • 举报
回复
事实证明不行
zhouing00 2011-01-20
  • 打赏
  • 举报
回复
为空时这样判断试试
if(X==""||x==null)
GUOCONG08 2011-01-20
  • 打赏
  • 举报
回复
谁能来点有建设性的答案?!
chocolee 2011-01-20
  • 打赏
  • 举报
回复
confirm放在前台js代码中
GUOCONG08 2011-01-20
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 intcry 的回复:]
return ;
[/Quote]
加哪 我加 confirm 后面 没用
西门喷血 2011-01-20
  • 打赏
  • 举报
回复
return ;
GUOCONG08 2011-01-20
  • 打赏
  • 举报
回复
function cc()
{
var xm=document.getElementByID("Projectname").value;
if(xm=="")
{
return confirm('您确定不登入项目吗?');
}
else return true;
}

这段东西写哪里?我是个新手
wdywqc 2011-01-20
  • 打赏
  • 举报
回复
看你的代码看的真晕...
一般判断为空的时候,不要这么些。
if(string.IsNullOrEmpty(strs))
{

}
IHandler 2011-01-20
  • 打赏
  • 举报
回复
把Response.Redirect("Manage/index.aspx");改为使用脚本试试
q107770540 2011-01-20
  • 打赏
  • 举报
回复
function cc()
{
var xm=document.getElementByID("Projectname").value;
if(xm=="")
{
return confirm('您确定不登入项目吗?');
}
else return true;
}

为dl这个button添加onclientClick属性: onClientClick="return cc();";

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧