Response.Write("<script>alert('Konaklama Başarıyla Eklendi')</script>");
string url = "NewAccommodation.aspx?mID=" + mID;
Response.Redirect(url);
嗨,在上面的代码中,它没有显示警告框,因为它后面的代码行。如何解决?
Response.Write("<script>alert('Konaklama Başarıyla Eklendi')</script>");
string url = "NewAccommodation.aspx?mID=" + mID;
Response.Redirect(url);
嗨,在上面的代码中,它没有显示警告框,因为它后面的代码行。如何解决?
处理极其有限的代码,在我看来,你有两个选择......
重定向到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>")
你为什么不试试这个
string url = "NewAccommodation.aspx?mID=" + mID;
Response.Redirect(url);
并将其放在 NewAccommodation.aspxpage_load
if(!IsPostBack)
Response.Write("<script>alert('Konaklama Başarıyla Eklendi')</script>");
Response.Redirect
向浏览器发送一个标头,使其导航到另一个 URL。作为它的标头,它位于响应的第一部分,因此它后面的任何不是标头(如您的输出)的内容都不会由浏览器处理。
你可以;
Response.Write("<script>alert('Konaklama Başarıyla Eklendi'); location.href='" + url + "'</script>");
You can try
Response.Write("alert('Konaklama Başarıyla Eklendi'); window.location.href='NewAccommodation.aspx?mID=" + mID +"'");
Happy coding!!!
你有两个选择