偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

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

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

先看看ASP.NET頁面刷新的實現(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.      //好像有些不對?   
  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+"秒后重刷本頁!"elsecurtime=cursec+"秒后重刷本頁!"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">自動刷新頁面< /FONT>< /P>   
  19. < /DIV> 

第六:

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

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

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

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

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

這時我們采用下面代碼試驗一下ASP.NET頁面刷新:

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

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

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

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

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

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

ASP.NET頁面刷新:自動刷新頁面的實現(xiàn)方法總結(jié):

1)

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

10表示間隔10秒刷新一次

2)

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

如果是你要刷新某一個iframe就把window給換成frame的名字或ID號

3)

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

4>

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

刷新本頁:

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

刷新父頁:

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

轉(zhuǎn)到指定頁:

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

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

'by aloxy

定時刷新:

1,

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

說明:url是要刷新的頁面URL地址

2000是等待時間=2秒,

2,

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

說明:

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

url is an absolute URL to be loaded.

n,是等待的時間,以秒為單位

url是要刷新的頁面URL地址

3,

  1. < %response.redirect url%> 

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

4,刷新框架頁  

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

彈出窗體后再刷新的問題

  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>"); 

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

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

在框架頁中右面刷新左面

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

頁面定時刷新功能實現(xiàn)

有三種方法:

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

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

定時刷新:

  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> 

一秒一次

頁面自動跳轉(zhuǎn):

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

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

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

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

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

點擊按鈕提交表單后刷新上級窗口

A窗口打開B窗口

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

最后要刷新A窗口

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

幾個javascript函數(shù)

//第一個自動關(guān)閉窗口

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

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

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

//第三個打開窗口

  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頁面刷新的問題,收藏這幾種方法會有用的。

【編輯推薦】

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

2009-07-24 10:53:51

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

2009-07-23 14:17:41

2009-07-29 17:26:39

ASP.NET頁面

2009-07-31 10:23:44

緩存頁面ASP.NET緩存

2009-08-03 13:38:18

ASP.NET編程模型

2011-06-08 10:28:15

ASP.Net

2011-07-13 08:58:51

ASP.NET

2009-08-17 09:24:25

ASP.NET控件

2009-08-25 17:42:41

ASP.NET新手問題

2009-07-27 15:25:40

aspx頁面ASP.NET

2009-07-31 10:33:54

ASP.NET頁面輸出

2009-08-05 18:22:55

2009-07-23 10:52:38

2009-07-29 14:35:34

頁面輸出緩存ASP.NET

2009-07-21 15:40:59

Asp.Net動態(tài)頁面

2009-07-28 16:40:11

ASP.NET異步頁面

2009-07-23 14:21:55

ASP.NET頁面

2012-04-13 10:05:24

ASP.NET

2009-07-29 16:31:39

ASP.NET安裝部署

2009-07-23 14:08:58

點贊
收藏

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