Reputation: 73
Response.Write("<script>alert('Konaklama Başarıyla Eklendi')</script>");
string url = "NewAccommodation.aspx?mID=" + mID;
Response.Redirect(url);
Hi, on the above code, it does not show the alert box because of the code lines after it. How to fix that?
Upvotes: 1
Views: 19741
Reputation: 9942
You can try
Response.Write("alert('Konaklama Başarıyla Eklendi'); window.location.href='NewAccommodation.aspx?mID=" + mID +"'");
Happy coding!!!
Upvotes: 0
Reputation: 19953
Working on your exceedingly limited code, you have two options as I see it...
Redirect to NewAccommodation.aspx
and then write the "alert" script from there
Or send the following....
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>")
Upvotes: 3
Reputation: 175766
Response.Redirect
sends a header to the browser that causes it to navigate to another URL. As its a header, its in the first part of the response so anything that follows it that isn't also header (like your output) is never handled by the browser.
Insted you can;
Response.Write("<script>alert('Konaklama Başarıyla Eklendi'); location.href='" + url + "'</script>");
Upvotes: 1
Reputation: 23551
You have two options
Upvotes: 0
Reputation: 19591
Why don't you try this
string url = "NewAccommodation.aspx?mID=" + mID;
Response.Redirect(url);
And put this on NewAccommodation.aspx page_load
if(!IsPostBack)
Response.Write("<script>alert('Konaklama Başarıyla Eklendi')</script>");
Upvotes: 2