![](/img/trans.png)
[英]How to redirect to a different page from a javascript alert box in a .net application?
[英]How do I show the Alert Box first and then redirect to any page with query strings?
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);
提前致謝
您的代碼有不必要的 (') 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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.