弹出错误框 停止运行

yanbinquan 2010-10-04 02:51:51
弹出错误框 停止运行
用return和if语句 直接跳出,对话框没有弹出
...全文
95 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Csdbfans 2010-10-04
  • 打赏
  • 举报
回复
改成下面的是一旦进入 if (strError!="")语句的话,就弹出一个输出框,然后你点完关闭,它就自动中转到create_an_account.aspx页面,难道不行吗?


string strError = "";
if (username_tbx.Text=="")
{
strError += "Login Name can't be null ";
}
if (password_tbx.Text=="")
{
strError += " Password can't be null";
}
if (strError!="")
{
Response.Write("<script>window.alert("+strError+");</script>");
Server.Transfer("create_an_account.aspx");
}
Csdbfans 2010-10-04
  • 打赏
  • 举报
回复
不是很明白你要什么效果的?
yanbinquan 2010-10-04
  • 打赏
  • 举报
回复
很奇怪 字段里面没有“can't be null”就没问题
yanbinquan 2010-10-04
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 csdbfans 的回复:]

.............
string strError = "";
if (username_tbx.Text=="")
{
strError += "Login Name can't be null ";
}
if (password_tbx.Tex……
[/Quote]

这个也是没有效果
Csdbfans 2010-10-04
  • 打赏
  • 举报
回复
.............
string strError = "";
if (username_tbx.Text=="")
{
strError += "Login Name can't be null ";
}
if (password_tbx.Text=="")
{
strError += " Password can't be null";
}
if (strError!="")
{
Response.Write("<script>window.alert("+strError+");location.href='create_an_account.aspx';</script>");
}
................

这一句改为:

Response.Write("<script>window.alert("+strError+");</script>");
Server.Transfer("create_an_account.aspx");
yanbinquan 2010-10-04
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 wuyq11 的回复:]

HttpContext.Current.Response.Write("<script language='javascript' type='text/javascript'>alert('"+msg+"');location.href='" + Src + "'</script>");
[/Quote]

这样写 后面的代码还是会执行
wuyq11 2010-10-04
  • 打赏
  • 举报
回复
HttpContext.Current.Response.Write("<script language='javascript' type='text/javascript'>alert('"+msg+"');location.href='" + Src + "'</script>");
yanbinquan 2010-10-04
  • 打赏
  • 举报
回复

现在我是这样写的

.............
string strError = "";
if (username_tbx.Text=="")
{
strError += "Login Name can't be null ";
}
if (password_tbx.Text=="")
{
strError += " Password can't be null";
}
if (strError!="")
{
Response.Write("<script>window.alert("+strError+");location.href='create_an_account.aspx';</script>");
}
................


就是想弹出错误提示框之后,后面的代码就不执行了
wuyq11 2010-10-04
  • 打赏
  • 举报
回复
贴出代码

62,046

社区成员

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

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

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

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