C # page refresh

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 'if (curmin! = 0
) Curtime = curmin + "Minute" + cursec + "second to refresh this page! "Elsecurtime = cursec +" refresh this page in seconds! "Window. status = curtimesetTimeout (
"Beginrefresh ()", 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

When writing ASP. Net programs, 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 window. location. href.
The statement can be used to refresh the page of another framework after the server code is executed (Response. Redirect cannot be reached, at least I did not find it ):

For example, the index.htm page has two frameworks:
FrameLeft and frameRight: Execute the server code on the frameRight page 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> your 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
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 a form value to determine whether an operation has occurred, and then use response. redirect
Refresh.

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)
Medium

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:
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.

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.