When writing ASP.Net programs, we often encounter the problem of page jumps. We often use Response.Redirect. If the customer wants to use prompts when jumping, this will not work, such as:
Response.Write(" <script>alert('Congratulations, your registration is successful!');</script>");
Response.Redirect("main.html");
At this time, our prompt content does not come out and jumps, which is no different from Response.Redirect("main.html");.
At this time, we use the following code to test it:
Response.Write("<script language=javascript>alert('Congratulations, your registration is successful!')</script>");
Response.Write("<script language=javascript>window.location.href='main.html'</script>");
This fulfills our requirements and jumps to the page after the prompt.
The most important thing is that the window.location.href statement can realize that the page of one frame refreshes the page of another frame after executing the server-side code (Response.Redirect cannot be reached, at least I have not found it):
For example: there are two in the index.htm page There are two frames, respectively frameLeft and frameRight. After executing the server-side code in the frameRight page, the page in frameLeft is refreshed.
The most common thing before was to automatically refresh the login box after registration, so that the login box is replaced by the logged-in page. As long as you add a paragraph after the successful registration code, you can refresh the page of another frame. The code is as follows:
Response.Write("<script language=javascript>alert('Congratulations, your registration is successful!')</script>");
Response.Write("<script language=javascript>window.parent.frameLeft.location.href='main.html'</script>");