Home  >  Article  >  Backend Development  >  How to implement ASP.NET page refresh

How to implement ASP.NET page refresh

巴扎黑
巴扎黑Original
2016-12-20 09:09:171161browse

< meta http-equiv="refresh" content="300; url=target.html"> Use window.location.href to refresh another frame page

When writing asp.net programs, we often encounter When it comes to jumping pages, 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, Registration successful! '); < /script>"); Response.Redirect("main.html"); At this time, our prompt content will not come out, and Response.Redirect("main.html"); There is no difference.

At this time, we use the following code to test the ASP.NET page refresh:

Response.Write("< script language=javascript>alert('Congratulations, 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 enable the page of one frame to refresh 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: index.htm There are two frames in the page, namely frameLeft and frameRight. After executing the server-side code in the frameRight page, the page in frameLeft is refreshed.

The most common thing previously 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, registration is successful!')< /script>"); Response.Write("< script language=javascript>window. parent.frameLeft.location.href='main.html'< /script>"); ASP.NET page refresh: summary of how to automatically refresh the page:

1)

< meta http-equiv="refresh "content="10; url=jumped page"> 10 means refresh every 10 seconds

2)

< script language=''javascript''> window.location.reload(true); < ; /script> If you want to refresh an iframe, replace window with the name or ID number of the frame

3)

< script language=''javascript''> window.navigate("This page url "); < /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 refresh page implementation methods (HTML, ASP, JS)

' by aloxy

Refresh regularly:

1,

< script>setTimeout("location.href='url '",2000)< /script> Description: url is the URL address of the page to be refreshed

2000 is the waiting time = 2 seconds,

2,

< meta name="Refresh" content="n; url "> Description:

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 to Refreshed page URL address

3,

< %response.redirect url%> Description: Generally, a url parameter or form value is used to determine whether an operation has occurred and then response.redirect is used to refresh.

4, Refresh the frame page

〈script language=javascript>top.leftFrm.location.reload(); parent.frmTop.location.reload(); < /script〉 Problem with refreshing the form after it 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"/> in the subform page code head

The refreshed content is added to if (!IsPostBack)

Refresh the left side on the right side of the frame page

//Refresh the left half of the frame page Response.Write("< script language=javascript>"); Response.Write("parent.left.location.href='PayDetailManage_Left.aspx'"); Response.Write("< ; /script>");
There are three ways to implement the scheduled page refresh function

:

1. Set it in html:

< title>xxxxx< /title> Then add the following line!

Refresh regularly:

< META HTTP-EQUIV="Refresh" content="10"> 10 represents the refresh interval, in seconds

2.jsp

< % response.setHeader("refresh", "1"); %> Refresh once every second

3. Use javascript:

< script language="javascript"> setTimeout("self.location.reload(); ",1000); < script> Once a second

The page automatically jumps:

1, set in html:

< title>xxxxx< /title> Then add the following line!

Regular jump and refresh:

< meta http-equiv="refresh" content="20; url=http://own URL">, where 20 means jumping to http after 20 seconds: //Own URL page.


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

A window opens B window

Then submit data in B to C window

Finally refresh A window

and close B window

Several javascript functions

//The first window to automatically close

< script language="javascript"> < !-- function clock(){i=i-1 document.title="This window will close in "+i+" seconds Automatically close!"; 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 function to open the window

< 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> Regarding the issue of asp.net page refresh, it will be useful to collect these methods

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn