javascript - 添加参数到 windows.location 现在页面不想重定向到所需的表单

标签 javascript c# asp.net

单击按钮时,我希望页面显示一个警报窗口,然后将用户重定向到不同的表单。最初没有添加任何参数,代码按照我想要的方式工作。添加参数后,页面不会重定向到表单。

Response.Write("<script>alert('Customer visit record for the visit has been created.You will now be taken to customer visit process.');"
                            + "window.location='CustomerVisit.aspx?bookingID="+cust_visit.BookingID.ToString()+
                            "&customerID="+cust_visit.CustomerID.ToString()+"</script>");

我想添加参数,以便我可以在下一个表单中使用它们:

Request.QueryString["bookingID"]

最佳答案

location的值需要用单引号括起来,建议后面跟分号:

Response.Write("<script>alert('...');"
    + "window.location = 'CustomerVisit.aspx?bookingID=" + cust_visit.BookingID.ToString()
    + "&customerID=" + cust_visit.CustomerID.ToString() + "';</script>");

关于javascript - 添加参数到 windows.location 现在页面不想重定向到所需的表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50690139/

相关文章:

javascript - 如何在 JavaScript 中获取 HTTP 回复?

javascript - HTML5 Canvas - 重复所有 Canvas 大小的文本

c# - 如何从 IEnumerable 创建多维数组

asp.net - 如何延迟 ASP.NET AutoPostBack 以便首先触发 JavaScript?

asp.net - 如何使用 EF 在开发数据库和实时数据库之间切换?

c# - 通过 JQuery 检查复选框时,复选框 OnCheckedChanged 不会触发

javascript - jQuery 更新 cookie 值

c# - 关闭应用程序并运行外部应用程序

c# - 我如何遵循 .Net Native 神秘的堆栈跟踪?

c# - Entity Framework 一对多查询