自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

ASP.NET頁(yè)面刷新方法總結(jié)

開(kāi)發(fā) 后端
本文介紹了asp.net頁(yè)面刷新的幾種方法。

先看看ASP.NET頁(yè)面刷新的實(shí)現(xiàn)方法:

第一:

  1. private void Button1_Click( object sender, System.EventArgs e )     
  2. {   
  3.      Response.Redirect( Request.Url.ToString( ) );   
  4. }  

第二:

  1. private void Button2_Click( object sender, System.EventArgs e )     
  2. {   
  3.      Response.Write( "   
  4.      < script language=javascript>window.location.href=document.URL;   
  5.      < /script>" );   
  6. }  

第三:

  1. private void Button3_Click( object sender, System.EventArgs e )     
  2. {   
  3.      Response.AddHeader( "Refresh","0" );   
  4. }   

第四:

  1. private void Button6_Click( object sender, System.EventArgs e )     
  2. {   
  3.      //好像有些不對(duì)?   
  4.      //Response.Write( "   
  5.      < script language=javascript>window.location.reload( );   
  6.      < /script>" );   
  7. }   

第五:

  1. < script>< !--   
  2. var limit="3:00"   
  3. if ( document.images )   
  4. {   
  5.      var parselimit=limit.split( ":" )parselimit=parselimit[0]*60+parselimit[1]*1   
  6. }   
  7. function beginrefresh( )   
  8. {   
  9.      if ( !document.images )returnif ( parselimit==1 )window.location.reload( )else   
  10.      {   
  11.          parselimit-=1curmin=Math.floor( parselimit/60 )cursec=parselimit%60if ( curmin!=0 )curtime=curmin+"分"+cursec+"秒后重刷本頁(yè)!"elsecurtime=cursec+"秒后重刷本頁(yè)!"window.status=curtimesetTimeout( "beginrefresh( )",1000 )   
  12.      }   
  13. }   
  14. window.onload=beginrefresh//-->   < /script>< DIV style="Z-INDEX: 102;   
  15. LEFT: 408px;   
  16. POSITION: absolute;   
  17. TOP: 232px" ms_positioning="text2D">   
  18. < P>< FONT size="3">自動(dòng)刷新頁(yè)面< /FONT>< /P>   
  19. < /DIV> 

第六:

  1. < meta http-equiv="refresh" content="300;   
  2. url=target.html">  

用window.location.href實(shí)現(xiàn)刷新另個(gè)框架頁(yè)面

在寫(xiě)asp.net程序的時(shí)候,我們經(jīng)常遇到跳轉(zhuǎn)頁(yè)面的問(wèn)題,我們經(jīng)常使用Response.Redirect ,如果客戶要在跳轉(zhuǎn)的時(shí)候使用提示,這個(gè)就不靈光了,如:

  1. Response.Write("< script>alert('恭喜您,注冊(cè)成功!');< /script>");  
  2. Response.Redirect("main.html");  
  3.  

這時(shí)候我們的提示內(nèi)容沒(méi)有出來(lái)就跳轉(zhuǎn)了,和Response.Redirect("main.html");沒(méi)有任何區(qū)別。

這時(shí)我們采用下面代碼試驗(yàn)一下ASP.NET頁(yè)面刷新:

  1. Response.Write("< script language=javascript>alert('恭喜您,注冊(cè)成功!')< /script>");  
  2. Response.Write("< script language=javascript>window.location.href='main.html'< /script>"); 

這個(gè)即實(shí)現(xiàn)了我們的要求,在提示后,跳轉(zhuǎn)頁(yè)面。

最重要的是window.location.href 語(yǔ)句可以實(shí)現(xiàn)一個(gè)框架的頁(yè)面在執(zhí)行服務(wù)器端代碼后刷新另一個(gè)框架的頁(yè)面(Response.Redirect無(wú)法達(dá)到,至少我沒(méi)有發(fā)現(xiàn)):

如:index.htm頁(yè)面中有二個(gè)框架,分別為 frameLeft和frameRight,在frameRight頁(yè)面中執(zhí)行服務(wù)器端代碼后刷新frameLeft中的頁(yè)面。

先前最常見(jiàn)的是注冊(cè)之后,自動(dòng)刷新登陸框,讓登陸框換成已登陸頁(yè)面,只要在注冊(cè)成功的代碼之后加上一段,即可以實(shí)現(xiàn)刷新另個(gè)框架的頁(yè)面。代碼如下:

  1. Response.Write("< script language=javascript>alert('恭喜您,注冊(cè)成功!')< /script>");  
  2. Response.Write("< script language=javascript>window.parent.frameLeft.location.href='main.html'< /script>");  
  3.  

ASP.NET頁(yè)面刷新:自動(dòng)刷新頁(yè)面的實(shí)現(xiàn)方法總結(jié):

1)

  1. < meta http-equiv="refresh"content="10;url=跳轉(zhuǎn)的頁(yè)面"

10表示間隔10秒刷新一次

2)

  1. < script language=''javascript''>  
  2. window.location.reload(true);  
  3. < /script> 

如果是你要刷新某一個(gè)iframe就把window給換成frame的名字或ID號(hào)

3)

  1. < script language=''javascript''>  
  2. window.navigate("本頁(yè)面url");  
  3. < /script> 

4>

  1. function abc()  
  2. {  
  3. window.location.href="/blog/window.location.href";  
  4. setTimeout("abc()",10000);  
  5. }  
  6.  

刷新本頁(yè):

  1. Response.Write("< script language=javascript>window.location.href=window.location.href;< /script>"

刷新父頁(yè):

  1. Response.Write("< script language=javascript>opener.location.href=opener.location.href;< /script>"

轉(zhuǎn)到指定頁(yè):

  1. Response.Write("< script language=javascript>window.location.href='yourpage.aspx';< /script>")  

刷新頁(yè)面實(shí)現(xiàn)方式總結(jié)(HTML,ASP,JS)

'by aloxy

定時(shí)刷新:

1,

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

說(shuō)明:url是要刷新的頁(yè)面URL地址

2000是等待時(shí)間=2秒,

2,

  1. < meta name="Refresh" content="n;url"

說(shuō)明:

n is the number of seconds to wait before loading the specified URL.

url is an absolute URL to be loaded.

n,是等待的時(shí)間,以秒為單位

url是要刷新的頁(yè)面URL地址

3,

  1. < %response.redirect url%> 

說(shuō)明:一般用一個(gè)url參數(shù)或者表單傳值判斷是否發(fā)生某個(gè)操作,然后利用response.redirect 刷新。

4,刷新框架頁(yè)  

  1. 〈script language=javascript>top.leftFrm.location.reload();parent.frmTop.location.reload();< /script〉 

彈出窗體后再刷新的問(wèn)題

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

在子窗體頁(yè)面代碼head中加入< base target="_self"/>

刷新的內(nèi)容加在    if (!IsPostBack) 中

在框架頁(yè)中右面刷新左面

  1. //刷新框架頁(yè)左半部分  
  2. Response.Write("< script language=javascript>");  
  3. Response.Write("parent.left.location.href='PayDetailManage_Left.aspx'");  
  4. Response.Write("< /script>"); 

頁(yè)面定時(shí)刷新功能實(shí)現(xiàn)

有三種方法:

1,在html中設(shè)置:

< title>xxxxx< /title>之後加入下面這一行即可!

定時(shí)刷新:

  1. < META HTTP-EQUIV="Refresh" content="10">  

10代表刷新間隔,單位為秒

2.jsp

  1. < % response.setHeader("refresh","1"); %> 

每一秒刷新一次

3.使用javascript:

  1. < script language="javascript">  
  2. setTimeout("self.location.reload();",1000);  
  3. < script> 

一秒一次

頁(yè)面自動(dòng)跳轉(zhuǎn):

1,在html中設(shè)置:

< title>xxxxx< /title>之後加入下面這一行即可!

定時(shí)跳轉(zhuǎn)并刷新:

  1. < meta http-equiv="refresh" content="20;url=http://自己的URL">, 

其中20指隔20秒后跳轉(zhuǎn)到http://自己的URL 頁(yè)面。

點(diǎn)擊按鈕提交表單后刷新上級(jí)窗口

A窗口打開(kāi)B窗口

然后在B里面提交數(shù)據(jù)至C窗口

最后要刷新A窗口

并且關(guān)閉B窗口

幾個(gè)javascript函數(shù)

//第一個(gè)自動(dòng)關(guān)閉窗口

  1. < script language="javascript">  
  2. < !--  
  3. function clock(){i=i-1  
  4. document.title="本窗口將在"+i+"秒后自動(dòng)關(guān)閉!";  
  5. if(i>0)setTimeout("clock();",1000);  
  6. else self.close();}  
  7. var i=2  
  8. clock();  
  9. //-->  
  10. < /script> 

//第二個(gè)刷新父頁(yè)面的函數(shù)

  1. < script language="javascript">  
  2. opener.location.reload();  
  3. < /script>  
  4.  

//第三個(gè)打開(kāi)窗口

  1. < script language="javascript">  
  2. function show(mylink,mytitle,width,height)  
  3. {mailwin=window.open(mylink,mytitle,'top=350,left=460,width='+width+',height='+height+',scrollbars=no')}  
  4. < /script> 

有關(guān)asp.net頁(yè)面刷新的問(wèn)題,收藏這幾種方法會(huì)有用的。

【編輯推薦】

  1. ASP.NET中的session存儲(chǔ)模式運(yùn)用
  2. ASP.NET中的文件上傳下載方法集合
  3. ASP.NET中的cookie讀寫(xiě)方法介紹
  4. ASP.NET中的javascript操作
  5. ASP.NET2.0中的單點(diǎn)登錄簡(jiǎn)介及實(shí)現(xiàn)
責(zé)任編輯:book05 來(lái)源: hi.baidu
相關(guān)推薦

2009-07-24 10:53:51

ASP.NET實(shí)現(xiàn)靜態(tài)

2009-07-29 17:26:39

ASP.NET頁(yè)面

2009-07-23 14:17:41

2009-07-31 10:23:44

緩存頁(yè)面ASP.NET緩存

2011-06-08 10:28:15

ASP.Net

2011-07-13 08:58:51

ASP.NET

2009-08-03 13:38:18

ASP.NET編程模型

2009-07-29 14:35:34

頁(yè)面輸出緩存ASP.NET

2009-07-23 10:52:38

2009-07-27 15:25:40

aspx頁(yè)面ASP.NET

2009-07-31 10:33:54

ASP.NET頁(yè)面輸出

2009-08-05 18:22:55

2009-07-21 15:40:59

Asp.Net動(dòng)態(tài)頁(yè)面

2009-07-23 14:21:55

ASP.NET頁(yè)面

2009-07-28 16:40:11

ASP.NET異步頁(yè)面

2009-08-17 09:24:25

ASP.NET控件

2009-08-25 17:42:41

ASP.NET新手問(wèn)題

2012-04-13 10:05:24

ASP.NET

2009-07-23 14:08:58

2009-07-31 13:06:53

CheckBoxLisASP.NET頁(yè)面
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)