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