6 Methods for implementing asp tutorial. net for automatic page refreshing
First:
Private void button#click (object sender, System. EventArgs e)
{
Response. Redirect (Request. Url. ToString ());
}
Second:
Private void Button2_Click (object sender, System. EventArgs e)
{
Response. Write ("
<Script language = webpage effect> window. location. href = document. URL;
</Script> ");
}
Third:
Private void Button3_Click (object sender, System. EventArgs e)
{
Response. AddHeader ("Refresh", "0 ");
}
Fourth:
Private void Button6_Click (object sender, System. EventArgs e)
{
// Does it seem wrong?
// Response. Write ("
<Script language = javascript> window. location. reload ();
</Script> ");
}
Fifth: (to be replaced <>)
<Script> <! --
Var limit = "3:00"
If (document. images)
{
Var parselimit = limit. split (":") parselimit = parselimit [0] * 60 + parselimit [1] * 1
}
Function beginrefresh ()
{
If (! Document. images) returnif (parselimit = 1) window. location. reload () else
{
Parselimit-= 1 curmin = Math. floor (parselimit/60) cursec = parselimit % 60if (curmin! = 0) curtime = curmin + "minute" + cursec + "second to refresh this page! "Elsecurtime = cursec +" refresh this page in seconds! "Window. status = curtimesetTimeout (" maid () ", 1000)
}
}
Window. onload = beginrefresh // --> </script> <DIV style = "Z-INDEX: 102;
LEFT: 408px;
POSITION: absolute;
TOP: 232px "ms_positioning =" text2D ">
<P> <FONT size = "3"> automatically refresh the page </FONT> </P>
</DIV> sixth:
<Meta http-equiv = "refresh" content = "300;
Url1_target.html ">
Use window. location. href to refresh another frame page (Reprinted from Smile) and reprinted from Smile
Write ASP. net program, we often encounter page jump problems, we often use Response. redirect: if the customer wants to use the prompt during the jump, this will not work, for example:
Response. Write ("<script> alert ('Congratulations, registration successful! '); </Script> ");
Response. Redirect ("main.html ");
At this time, our prompt content will jump without coming out, and there is no difference with Response. Redirect ("main.html.
Then we use the following code to test:
Response. Write ("<script language = javascript> alert ('Congratulations, registration successful! ') </Script> ");
Response. Write ("<script language = javascript> commandid location.href+'main.html '</script> ");
This allows us to jump to the page after the prompt.
The most important thing is that the window. location. href statement can implement a framework page, refresh the page of another framework after executing the server code (Response. Redirect cannot be reached, at least I did not find it ):
For example, the index.htm page has two frameworks: frameLeft and frameRight. On the frameRight page, execute the server code and refresh the page in frameLeft.
Previously, the most common issue was to automatically refresh the login box after registration and change the login box to the logged-on page. You only need to add a section after the successfully registered code, that is, you can refresh the page of another framework. The code is as follows:
Response. Write ("<script language = javascript> alert ('Congratulations, registration successful! ') </Script> ");
Response. Write ("<script language = javascript> Response parent.frameleft.location.href+'main.html '</script> ");