如何首先显示警报框,然后重定向到包含查询字符串的任何页面?

时间:2012-04-10 06:30:43

标签: c#

ScriptManager.RegisterStartupScript(UpdatePanel2, this.GetType(), "click", "alert('This Email address is already registered...');window.location.href ='test.aspx'", true);

通过使用上面的代码,我能够显示警告框,然后重定向到test.aspx页面。

但是当我必须传递具有以下地址的查询字符串时会出现问题:

ScriptManager.RegisterStartupScript(UpdatePanel2, this.GetType(), "click", "alert('This Email address is already registered...');window.location.href ='test.aspx?WidgetID='" + Request.QueryString["WidgetID"] + "'&lan='" + readCookie() + "'&seeHome=true'", true);

提前致谢

1 个答案:

答案 0 :(得分:0)

您的代码有不必要的('),它会破坏javascript中的字符串。试试这个

ScriptManager.RegisterStartupScript(UpdatePanel2, this.GetType(), "click", "alert('This Email address is already registered...');window.location.href ='test.aspx?WidgetID=" + Request.QueryString["WidgetID"] + "&lan=" + readCookie() + "&seeHome=true'", true);