Response.Write("<script>alert('Konaklama Başarıyla Eklendi')</script>");
string url = "NewAccommodation.aspx?mID=" + mID;
Response.Redirect(url);
嗨,在上面的代码中,它没有显示警告框,因为它后面的代码行。如何解决?
答案 0 :(得分:3)
使用极其有限的代码,我有两种选择......
重定向到NewAccommodation.aspx
,然后从那里写“警报”脚本
或发送以下内容....
Response.Write("<script type='text/javascript'>")
Response.Write("alert('Konaklama Başarıyla Eklendi');")
Response.Write("document.location.href='NewAccommodation.aspx?mID=" + mID.ToString() + "';")
Response.Write("</script>")
答案 1 :(得分:2)
你为什么不试试这个
string url = "NewAccommodation.aspx?mID=" + mID;
Response.Redirect(url);
并将其放在NewAccommodation.aspx page_load
if(!IsPostBack)
Response.Write("<script>alert('Konaklama Başarıyla Eklendi')</script>");
答案 2 :(得分:1)
Response.Redirect
向浏览器发送标题,导致其导航到另一个网址。作为一个标题,它在响应的第一部分,所以跟随它的任何东西都不是标题(就像你的输出一样)从不被浏览器处理。
Insted you can;
Response.Write("<script>alert('Konaklama Başarıyla Eklendi'); location.href='" + url + "'</script>");
答案 3 :(得分:0)
您有两个选择
答案 4 :(得分:0)
你可以尝试
Response.Write(“alert('KonaklamaBaşarıylaEklendi'); window.location.href ='NewAccommodation.aspx?mID =”+ mID +“'”);
快乐的编码!!!