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

C# 如何首先显示警报框,然后重定向到任何带有查询字符串的页面?,c#,C#,通过使用上面的代码,我可以显示警报框,然后重定向到test.aspx页面 但当我必须传递带有如下地址的查询字符串时,就会出现问题: 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'", true);

提前感谢

您的代码有不必要的(')s,这会破坏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);
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);