-1

当我尝试执行此操作时,不加载警报消息,它会立即导航到 homeNew.aspx 页面。但是当重定向代码不可用时,警报消息会正确弹出......我需要这两个功能,这意味着在单击“确定”到警报消息后它应该被重定向到下一页..请帮助我克服这个问题问题。

if (TextBox2.Text == nic)
{
    Response.Write(@"<script language='javascript'>alert('Check your email to retrieve your user name and password!')</script>");
    Response.Redirect("homeNew.aspx");
    connection.Close();
}
else
{
    Response.Write(@"<script language='javascript'>alert('INVALID Email address and NIC combination, Try Again!')</script>");
}
4

2 回答 2

1

“由于重定向,您编写的 java 脚本不是由浏览器运行的。您可以在 javascript 中编写重定向代码。

if (TextBox2.Text == nic)
{
    Response.Write(@"<script language='javascript'>alert('Check your email to retrive your user name and password!'); window.location=""/homeNew.aspx""</script>");
}
else
{
    Response.Write(@"<script language='javascript'>alert('INVALID Email address and NIC combination, Try Again!')</script>");
}
于 2013-06-08T07:18:07.597 回答
0
alert('Check your email to retrive your user name and password!');
window.location = '/homeNew.aspx';

您需要在脚本标签内执行这两项操作。

于 2013-06-08T07:14:36.520 回答