ASP.NET page refresh implementation method of includes html js

  • 2020-05-09 18:26:38
  • OfStack

Let's take a look at the implementation of ASP.NET page refresh:
1:

C# code
private void Button1_Click( object sender, System.EventArgs e )
{
Response.Redirect( Request.Url.ToString( ) );
}

2:
C# code
private void Button2_Click( object sender, System.EventArgs e )
{
Response.Write( " < script language=javascript > window.location.href=document.URL; < /script > " );
}

3:
C# code
private void Button3_Click( object sender, System.EventArgs e )
{
Response.AddHeader( "Refresh","0" );
}

4:
C# code
private void Button6_Click( object sender, System.EventArgs e )
{
// there seems to be something wrong?
//Response.Write( " < script language=javascript > window.location.reload( ); < /script > " ); }

5:
HTML code
< 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-=1curmin= Math.floor (parselimit/60)cursec=parselimit%60if (curmin! =0)curtime=curmin+" minutes "+cursec+" elsecurtime=cursec+" rescroll 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" > Automatic page refresh < /FONT > < /P > < /DIV >

6:
< meta http-equiv="refresh" content="300; url=target.html" > Refresh another frame page with window.location.href
When writing asp.net, we often encounter the problem of jumping pages. We often use Response.Redirect.
Response.Write(" < script > alert(' congratulations, registration is successful! '); < /script > "); Response. Redirect (" main html "); At this point our prompt content does not come out jump, and Response.Redirect (" main.html "); It doesn't make any difference.
ASP. NET page refresh using the following code experiment 1:
Response.Write(" < script language=javascript > 'congratulations, you're registered! ') < /script > "); Response.Write(" < script language=javascript > window.location.href='main.html' < /script > "); This is the realization of our requirements, after the prompt, jump to the page.
Most importantly, the window.location.href statement enables the page of one frame to refresh the page of the other after executing the server-side code (Response.Redirect cannot, at least I didn't notice) :
For example, there are two frames in index.htm page, frameLeft and frameRight respectively. After executing the server-side code in frameRight page, refresh the page in frameLeft.
Previously, the most common is after registration, automatically refresh the login box, so that the login box is replaced by the logged in page, as long as after the successful registration of the code plus 1 paragraph, that can be realized to refresh the page of another framework. 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 the implementation method of automatic page refresh:
1)
< meta http - equiv = "refresh content = 10; url= jump page "" > 10 represents a refresh of 10 seconds
2)
< script language=''javascript'' > window.location.reload(true); < /script > If you want to refresh an iframe, replace window with the frame name or ID number
3)
< script language=''javascript'' > window.navigate(" url on this page "); < /script > 4 >
function abc () {window. location. href = ". / blog window. location href "; abc setTimeout (" () ", 10000); } refresh this page:
Response.Write(" < script language=javascript > window.location.href=window.location.href; < /script > ") refresh parent page:
Response.Write(" < script language=javascript > opener.location.href=opener.location.href; < /script > ") to the specified page:
Response.Write(" < script language=javascript > window.location.href='yourpage.aspx'; < /script > ")
Summary of page refresh implementation (HTML,ASP,JS)
'by aloxy
Timed refresh:
1,
< script > setTimeout("location.href='url'",2000) < /script > Note: url is the URL address of the page to be refreshed
2000 is the wait 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 time to wait, in seconds
url is the URL address of the page to be refreshed
3,
< %response.redirect url% > Note: 1 use 1 url parameter or form pass value to determine whether an operation has occurred and then refresh using response.redirect.
4. Refresh the frame page
The < script language = javascript > top.leftFrm.location.reload(); parent.frmTop.location.reload(); < /script > pop-up window and then refresh the problem
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 to the subform page code head < base target="_self"/ >
The refreshed content is added to if (! IsPostBack)
In the frame page, the right side refreshes the left side
// 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 > ");
Page regular refresh function
There are three ways:
1. Set in html:
< title > xxxxx < /title > Then add the following line!
Timed refresh:
< META HTTP-EQUIV="Refresh" content="10" > 10 represents the refresh interval in seconds
2.jsp
< % response.setHeader("refresh","1"); % > Refresh every 1 second
3. Use javascript:
< script language="javascript" > setTimeout("self.location.reload(); ",1000); < script > 1 1 second
Page automatically redirects:
1. Set in html:
< title > xxxxx < /title > Then add the following line!
Timed jump and refresh:
< meta http - equiv = "refresh content = 20; url=http:// own URL" > , where 20 refers to the jump to http:// own URL page after 20 seconds.
Click the button to submit the form and refresh the parent window
A window opens B window
Then submit the data to the C window in B
Finally, refresh the A window
And close the B window
Several javascript functions
// the first window closes automatically
< script language="javascript" > < ! -- function clock(){i= i-1 document. title=" this window will close automatically after "+i+"!" ; if (i > 0)setTimeout("clock(); ",1000); else self.close(); } var i=2 clock(); //-- > < /script > // the second function that refreshes 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 > For the asp.net page refresh, these methods can be useful.

Related articles: