ASP.NET页面刷新方法总结(收藏)

2012 年 12 月 1 日6730

ASP.NET页面刷新方法总结(收藏)

上一篇 /

下一篇 2010-09-14 13:41:34

/ 精华(1)

/ 置顶(3)

/ 个人分类:.net学习经验

/

/

先看看ASP.NET页面刷新的实现方法:
b0M\0eg XQ"^Eh0ITPUB个人空间k'I`j(b
第一:ITPUB个人空间!D#Xv2h}g9b&W8q g
ITPUB个人空间-S"NK"r}9^
private void Button1_Click( object sender, System.EventArgs e ) { Response.Redirect( Request.Url.ToString( ) ); } 第二:
c| p(^H[TzJmo0
RXy}Bc"A8yPq+j0private void Button2_Click( object sender, System.EventArgs e ) { Response.Write( " < script. language=javascript>window.location.href=document.URL; < /script>" ); } 第三:
/\]`2z/e$r+oH0
;fzH#C4i2X$z

PQ0private void Button3_Click( object sender, System.EventArgs e ) { Response.AddHeader( "Refresh","0" ); } 第四:
!xZ1`j4Q'\Q`0
v"n0K#ub0private void Button6_Click( object sender, System.EventArgs e ) { //好像有些不对? //Response.Write( " < script. language=javascript>window.location.reload( ); < /script>" ); } 第五:
8M w],l

fD~m0ITPUB个人空间Jk0F

\C*i:d
ITPUB个人空间Pi5TIP_6f!}u
< 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+"分"+cursec+"秒后重刷本页!"elsecurtime=cursec+"秒后重刷本页!"window.status=curtimesetTimeout( "beginrefresh( )",1000 ) } } window.onload=beginrefresh//--> < /script>< DIV ms_positioning="text2D"> < P>< FONT size="3">自动刷新页面< /FONT>< /P> < /DIV> 第六:ITPUB个人空间Yz's1Z$F N6@+Q,E5V

C4yTC3`&M9N*And7P0< meta. http-equiv="refresh" content="300; url=target.html"> 用window.location.href实现刷新另个框架页面
]T I7~m3T!KE0ITPUB个人空间?N$h_4[PV9V
在写asp.net程序的时候,我们经常遇到跳转页面的问题,我们经常使用Response.Redirect ,如果客户要在跳转的时候使用提示,这个就不灵光了,如:ITPUB个人空间?'`

ew+YV$c

!q |adWl.v#Uw:j0Response.Write("< script>alert('恭喜您,注册成功!'); < /script>"); Response.Redirect("main.html"); 这时候我们的提示内容没有出来就跳转了,和Response.Redirect("main.html"); 没有任何区别。
gbdzz ~6_"SS

cX~0ITPUB个人空间Lh/hb{_2pPt
这时我们采用下面代码试验一下ASP.NET页面刷新:
Cz?c^0
ynK/V3~r/u0Response.Write("< script. language=javascript>alert('恭喜您,注册成功!')< /script>"); Response.Write("< script. language=javascript>window.location.href='main.html'< /script>"); 这个即实现了我们的要求,在提示后,跳转页面。ITPUB个人空间F

I8ZH4W

< meta. http-equiv="refresh"content="10; url=跳转的页面"> 10表示间隔10秒刷新一次ITPUB个人空间,l(ri6T6q*U,{&U

s6u

\Twm4`t)o&v02)ITPUB个人空间;JdA

g%f$?+_&}

Response.Write("< script. language=javascript>window.location.href=window.location.href; < /script>") 刷新父页:ITPUB个人空间xL,z

s~1U\
ITPUB个人空间#g0r L2G0XH
Response.Write("< script. language=javascript>opener.location.href=opener.location.href; < /script>") 转到指定页:ITPUB个人空间3d7_S!g

QiTH&H+I,D
ITPUB个人空间K#PDv8@ o7v

j
Response.Write("< script. language=javascript>window.location.href='yourpage.aspx'; < /script>")
z0G#f@D/flq0刷新页面实现方式总结(HTML,ASP,JS)ITPUB个人空间z6e0Oh+|FfKR:K

N6SL R+Ai*Qp0'by aloxyITPUB个人空间&t5Ii:Ej[2M

6xm;Vw.e:z]0定时刷新:
7AO)umym ?_0

BYv5?.c01,
VP|/z&|6u0
@

csl1S0< script>setTimeout("location.href='url'",2000)< /script> 说明:url是要刷新的页面URL地址
'|

`kg1iC

G

C9[0

n is the number of seconds to wait before loading the specified URL.
.UL4^DA(M+hB0

h+Z~.q&q3@_KD0url is an absolute URL to be loaded.ITPUB个人空间6l gT9bi

OI+Upw0n,是等待的时间,以秒为单位ITPUB个人空间'|1`rT.?*G_A
ITPUB个人空间%a4`mv

P;xF6PP
url是要刷新的页面URL地址

< %response.redirect url%> 说明:一般用一个url参数或者表单传值判断是否发生某个操作然后利用response.redirect 刷新。ITPUB个人空间q.TbWq.fYt4}^I

t+h
ITPUB个人空间d(^8y c~P(be|l%`
4,刷新框架页
Fb9_5ju5b

z:]"@&U#I0ITPUB个人空间fI,ssffw
〈script. language=javascript>top.leftFrm.location.reload(); parent.frmTop.location.reload(); < /script〉 弹出窗体后再刷新的问题
je/o/t

[tI0
V(M&r3aw-_$V0Response.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>"); 在子窗体页面代码head中加入< base target="_self"/>ITPUB个人空间

O[w3c3x4f$z

sw'gI Y0刷新的内容加在 if (!IsPostBack) 中ITPUB个人空间5kl/Ej+u6]bJO

.`5cY?k0在框架页中右面刷新左面ITPUB个人空间T)S8{_3eC'i

5{2e wut5nWmt0//刷新框架页左半部分 Response.Write("< script. language=javascript>"); Response.Write("parent.left.location.href='PayDetailManage_Left.aspx'"); Response.Write("< /script>");
]

mD:o!k0页面定时刷新功能实现
< % response.setHeader("refresh","1"); %> 每一秒刷新一次
F_ C

M%e3zjb0

l9g;iZ$^03.使用javascript.:
@nkJg!E7t0
}j2{#e!W2T7@;pW,My0< script. language="javascript"> setTimeout("self.location.reload(); ",1000); < script> 一秒一次
(No6D0cr0
;I&q+E|E rM4Zz0页面自动跳转:ITPUB个人空间$rR(V.P } P1Ly

,w1Pz2XhKnp

q%Yp01,在html中设置:ITPUB个人空间 H;g7Ny I#P \
ITPUB个人空间Tn6k#a9m!U-Q#e
< title>xxxxx< /title>之後加入下面这一行即可!ITPUB个人空间6`$[:YQXb

7I cNN4oS)g0定时跳转并刷新:ITPUB个人空间4]l,s:]H3`
ITPUB个人空间wH"On"n
< meta. http-equiv="refresh" content="20; url=http://自己的URL">, 其中20指隔20秒后跳转到http://自己的URL 页面。
(C$PzhX6I~9w/b0S0ITPUB个人空间C p

Um-T'{9tw

]J${J&}i+ai0点击按钮提交表单后刷新上级窗口ITPUB个人空间Qw4V%a8C"J;\
ITPUB个人空间|pw-j*fS

J'gg
A窗口打开B窗口

< script. language="javascript"> < !-- function clock(){i=i-1 document.title="本窗口将在"+i+"秒后自动关闭!"; if(i>0)setTimeout("clock(); ",1000); else self.close(); } var i=2 clock(); //--> < /script> //第二个刷新父页面的函数
+U9~3q%Nk0
fPD-{$M}W5R9U0< script. language="javascript"> opener.location.reload(); < /script> //第三个打开窗口ITPUB个人空间8lP}Nc.jf@7f
ITPUB个人空间r F|u4]b C1\
< 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> 有关asp.net页面刷新的问题,收藏这几种方法会有用的。

相关阅读:

TAG:

mvc

公牛 / 2012-07-17 09:05:32

Guest / 2012-07-17 09:05:14

评 5 分

yi7589 / 2012-07-01 15:38:14

本文推荐:

<a href="http://http://www.zjjv.com//">风淋室</a>

<a href="http://http://www.zjjv.com//">高效空气过滤器</a>

<a href="http://http://www.zjjv.com//">传递窗</a>

<a href="http://http://www.zjjv.com//">KLC风淋室</a>

<a href="http://http://www.zjjv.com///product/20111106102612.html">多人风淋通道</a>

<a href="http://http://www.zjjv.com///product/20111222235555.html">洁净手术室送风天花</a>

<a href="http://http://www.zjjv.com///category/gaoxiaosongfengkou/">高效送风口</a>

<a href="http://http://www.zjjv.com///category/fenglinshibiaozhun/">风淋室标准</a>

<a href="http://http://www.zjjv.com///article/20111206091906.html">无尘车间管理规范</a>

TT / 2010-11-18 15:58:18

<a href="http://http://www.zjjv.com//.cn/html/chaoguruanjian">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///">专业炒股软件下载 下载站</a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///">手机专业炒股软件下载</a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

<a href="http://http://www.zjjv.com///adcgrj.html" target="_blank">专业炒股软件下载 </a>

ASP.NET页面刷新方法总结(收藏)这篇文章已被推荐到.NET企业技术交流圈子中。

0 0