An error occurred while refreshing the asp.net page.

Source: Internet
Author: User

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 = javascript> 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 framework page
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> ");

Summary of the implementation methods of the automatic refresh page:

1)
<Meta http-equiv = "refresh" content = "10; url = redirected page">
10 indicates refreshing every 10 seconds.
2)
<Script language = ''javascript ''>
Window. location. reload (true );
</Script>
If you need to refresh an iframe, replace the window with the frame name or ID.
3)
<Script language = ''javascript ''>
Window. navigate ("url of this page ");
</Script>
4>

Function abc ()
{
Window. location. href = "/blog/window. location. href ";
SetTimeout ("abc ()", 10000 );
}

Refresh this page:
Response. Write ("<script language = javascript> window. location. href = window. location. href; </script> ")

Refresh the parent page:
Response. Write ("<script language = javascript> opener. location. href = opener. location. href; </script> ")

Go to the specified page:
Response. Write ("<script language = javascript> window. location. href = 'yourpage. aspx '; </script> ")

Summary of page refreshing implementation (HTML, ASP, JS)
'By aloxy

Timed Refresh:
1, <script> setTimeout ("location. href = 'url'", 2000) </script>

Note: The url is the URL of the page to be refreshed.
2000 is the waiting time = 2 seconds,

2, <meta name = "Refresh" content = "n; url">

Note:
N is the number of seconds to wait before loading the specified URL.
Url is an absolute URL to be loaded.
N is the waiting time, in seconds.
Url is the URL of the page to be refreshed

3, <% response. redirect url %>

Note: Generally, you can use a url parameter or form value to determine whether an operation has occurred, and then use response. redirect to refresh the operation.

4. Refresh the framework page
<Script language = javascript> top. leftFrm. location. reload (); parent. frmTop. location. reload (); </script> 〉

Refresh after the window pops up

Response. write ("<script> window. showModalDialog ('.. /OA/SPCL. aspx ', window, 'dialogheight: 300px; dialogWidth: 427px; dialogTop: 200px; dialogLeft: 133px') </script> "); // open
Response. Write ("<script> document. location = document. location; </script> ");

Add <base target = "_ self"/>

Add the refreshed content to if (! IsPostBack)

Refresh the left side on the right side of the frame page
// Refresh the left half of the Framework page
Response. Write ("<script language = javascript> ");
Response. Write ("parent. left. location. href = 'paydetailmanage _ Left. aspx '");
Response. Write ("</script> ");

Implementation of the page timed refresh function

There are three methods:
1. Set in html:
<Title> xxxxx </title> and add the following line!
Timed Refresh: <META HTTP-EQUIV = "Refresh" content = "10">
10 indicates the refresh interval, in seconds.

2. jsp
<% Response. setHeader ("refresh", "1"); %>
Refresh Every second

3. Use javascript:
<Script language = "javascript">
SetTimeout ("self. location. reload ();", 1000 );
<Script>
One second

Automatic page Jump:
1. Set in html:
<Title> xxxxx </title> and add the following line!
Timed jump and refresh: <meta http-equiv = "refresh" content = "20; url = http: // your own URL">,
Among them, 20 refers to jump to the http: // own URL page every 20 seconds.

Click the button to submit the form and refresh the upper-level window.

Window A opens window B

Then, submit data in B to the C window.

Last, refresh window.

And close window B.

Several javascript Functions

// The first window is automatically closed
<Script language = "javascript">
<! --
Function clock () {I = I-1
Document. title = "this window will be closed automatically after" + I + "seconds! ";
If (I> 0) setTimeout ("clock ();", 1000 );
Else self. close ();}
Var I = 2
Clock ();
// -->
</Script>

// The second function to refresh the parent page

<Script language = "javascript">
Opener. location. reload ();
</Script>

// The third window opens

<Script language = "javascript">
Function show (mylink, mytitle, width, height)
{Mailwin = window. open (mylink, mytitle, 'top = 350, left = 460, width = '+ width +', height = '+ height +', scrollbars = no ')}
</Script>

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 = javascript> 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 framework page
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> ");

Summary of the implementation methods of the automatic refresh page:

1)
<Meta http-equiv = "refresh" content = "10; url = redirected page">
10 indicates refreshing every 10 seconds.
2)
<Script language = ''javascript ''>
Window. location. reload (true );
</Script>
If you need to refresh an iframe, replace the window with the frame name or ID.
3)
<Script language = ''javascript ''>
Window. navigate ("url of this page ");
</Script>
4>

Function abc ()
{
Window. location. href = "/blog/window. location. href ";
SetTimeout ("abc ()", 10000 );
}

Refresh this page:
Response. Write ("<script language = javascript> window. location. href = window. location. href; </script> ")

Refresh the parent page:
Response. Write ("<script language = javascript> opener. location. href = opener. location. href; </script> ")

Go to the specified page:
Response. Write ("<script language = javascript> window. location. href = 'yourpage. aspx '; </script> ")

Summary of page refreshing implementation (HTML, ASP, JS)
'By aloxy

Timed Refresh:
1, <script> setTimeout ("location. href = 'url'", 2000) </script>

Note: The url is the URL of the page to be refreshed.
2000 is the waiting time = 2 seconds,

2, <meta name = "Refresh" content = "n; url">

Note:
N is the number of seconds to wait before loading the specified URL.
Url is an absolute URL to be loaded.
N is the waiting time, in seconds.
Url is the URL of the page to be refreshed

3, <% response. redirect url %>

Note: Generally, you can use a url parameter or form value to determine whether an operation has occurred, and then use response. redirect to refresh the operation.

4. Refresh the framework page
<Script language = javascript> top. leftFrm. location. reload (); parent. frmTop. location. reload (); </script> 〉

Refresh after the window pops up

Response. write ("<script> window. showModalDialog ('.. /OA/SPCL. aspx ', window, 'dialogheight: 300px; dialogWidth: 427px; dialogTop: 200px; dialogLeft: 133px') </script> "); // open
Response. Write ("<script> document. location = document. location; </script> ");

Add <base target = "_ self"/>

Add the refreshed content to if (! IsPostBack)

Refresh the left side on the right side of the frame page
// Refresh the left half of the Framework page
Response. Write ("<script language = javascript> ");
Response. Write ("parent. left. location. href = 'paydetailmanage _ Left. aspx '");
Response. Write ("</script> ");

Implementation of the page timed refresh function

There are three methods:
1. Set in html:
<Title> xxxxx </title> and add the following line!
Timed Refresh: <META HTTP-EQUIV = "Refresh" content = "10">
10 indicates the refresh interval, in seconds.

2. jsp
<% Response. setHeader ("refresh", "1"); %>
Refresh Every second

3. Use javascript:
<Script language = "javascript">
SetTimeout ("self. location. reload ();", 1000 );
<Script>
One second

Automatic page Jump:
1. Set in html:
<Title> xxxxx </title> and add the following line!
Timed jump and refresh: <meta http-equiv = "refresh" content = "20; url = http: // your own URL">,
Among them, 20 refers to jump to the http: // own URL page every 20 seconds.

Click the button to submit the form and refresh the upper-level window.

Window A opens window B

Then, submit data in B to the C window.

Last, refresh window.

And close window B.

Several javascript Functions

// The first window is automatically closed
<Script language = "javascript">
<! --
Function clock () {I = I-1
Document. title = "this window will be closed automatically after" + I + "seconds! ";
If (I> 0) setTimeout ("clock ();", 1000 );
Else self. close ();}
Var I = 2
Clock ();
// -->
</Script>

// The second function to refresh the parent page

<Script language = "javascript">
Opener. location. reload ();
</Script>

// The third window opens

<Script language = "javascript">
Function show (mylink, mytitle, width, height)
{Mailwin = window. open (mylink, mytitle, 'top = 350, left = 460, width = '+ width +', height = '+ height +', scrollbars = no ')}
</Script>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.