簡體   English   中英

我如何先顯示警告框,然后重定向到帶有查詢字符串的任何頁面?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM