asp.net page Refresh implementation method (including HTML,JS) _ Practical skills

Source: Internet
Author: User
First look at the ASP.net page Refresh implementation method:
First:

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

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

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

Fourth:
C # code
private void Button6_click (object sender, System.EventArgs e)
{
Like something's wrong?
Response.Write ("< script language=javascript>window.location.reload ();" </script> "); }

Fifth:
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+ "min" +cursec+ "Second after the brush this page!" "elsecurtime=cursec+" seconds after the brush this page! "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 "> Auto Refresh Page </font></p> </div>

Sixth:
< meta http-equiv= "Refresh" content= "300; Url=target.html "> Refresh another frames page with WINDOW.LOCATION.HREF implementation
In writing ASP.net program, we often encounter the problem of the jump page, we often use Response.Redirect, if the customer wants to jump in the use of tips, this is not a good idea, such as:
Response.Write ("< Script>alert" ("Congratulations, registration success!") '); </script> "); Response.Redirect ("main.html"); At this time our prompt content did not come out on the jump, and Response.Redirect ("main.html"); without any distinction.
Then we use the following code to test the ASP.net page refresh:
Response.Write ("< script Language=javascript>alert" (' Congratulations, registration success!) ') </script> "); Response.Write ("< script language=javascript>window.location.href= ' main.html ' </script>"); This is the realization of our requirements, in the prompt after the jump page.
The most important thing is that the WINDOW.LOCATION.HREF statement can implement a frame of the page after executing the server-side code to refresh another frame of the page (Response.Redirect cannot be reached, at least I did not find):
For example, there are two frames in the index.htm page, Frameleft and Frameright, which refresh the page in the Frameleft after the server-side code is executed on the Frameright page.
Before the most common is registered, automatically refresh the landing box, so that the landing box into the landing page, as long as the registration of successful code after the addition of a paragraph, that can be implemented to refresh another frame of the page. The code is as follows:
Response.Write ("< script Language=javascript>alert" (' Congratulations, registration success!) ') </script> "); Response.Write ("< script language=javascript>window.parent.frameleft.location.href= ' main.html ' </script > "); Asp. NET page refresh: Automatic refresh of the page implementation method Summary:
1)
< meta http-equiv= "Refresh" content= "10; Url= jump Page "> 10 indicates a refresh interval of 10 seconds
2)
< script language= ' JavaScript ' > Window.location.reload (TRUE); </script> If you want to refresh an iframe, replace the 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 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> ")
Refresh page Implementation Summary (HTML,ASP,JS)
' By Aloxy
Timed refresh:
1,
< Script>settimeout ("location.href= ' url" ",") </script> Description: URL is the page URL address to refresh
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 a 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%> Description: Generally use a URL parameter or table conveys value to determine whether an operation occurs and then use Response.Redirect refresh.
4, refresh the frames page
〈script language=javascript>top.leftfrm.location.reload (); Parent.frmTop.location.reload (); </script〉 a pop-up form 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> "); In the subform page code head, add < base target= "_self"/>
The refreshed content is added to the IF (! IsPostBack) in
Flush the left side of the frame page
Refreshes 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 timed Refresh function implementation
There are three different ways:
1, set in HTML:
< Title>xxxxx </title> after joining the following line!
Timed refresh:
< META http-equiv= "Refresh" content= "ten" > 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
Page Auto Jump:
1, set in HTML:
< Title>xxxxx </title> after joining the following line!
Timed Jump and Refresh:
< meta http-equiv= "Refresh" content= "20; url=http://own url "", where 20 points to 20 seconds after the jump to http://own url page.
Click the button to submit the form and refresh the parent window
A window opens the b window
And then submit the data to the C window in B.
Last to refresh window a
and close the b window
Several JavaScript functions
First Auto Close window
< script language= "JavaScript" > <!--function Clock () {i=i-1 document.title= "This window will automatically close after" +i+ "seconds!"; if (i>0) settimeout ("clock ();", 1000); else Self.close (); var i=2 clock (); --> </script>//second function to refresh the parent page
< script language= "JavaScript" > Opener.location.reload (); </script>//Third open 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> questions about ASP.net page refreshes, It can be useful to collect these several methods.
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.