ASP.NET页面刷新的几种实现方法

作者:袖梨 2022-06-25

asp教程.net页面刷新的几种实现方法

第一:
c# codeprivate void button1_click( object sender, system.eventargs e )
{
response.redirect( request.url.tostring( ) );
}

第二:
c# codeprivate void button2_click( object sender, system.eventargs e )
{
response.write( " 网页特效>window.location.href=document.url; " );
}

第三:
c# codeprivate void button3_click( object sender, system.eventargs e )
{
response.addheader( "refresh","0" );
}

第四:
c# codeprivate void button6_click( object sender, system.eventargs e )
{
//好像有些不对?
//response.write( " 网页特效>window.location.reload( ); " ); }

第五:
html code 自动刷新页面

第六:
用window.location.href实现刷新另个框架页面

在写asp.net教程程序的时候,我们经常遇到跳转页面的问题,我们经常使用response.redirect ,如果客户要在跳转的时候使用提示,这个就不灵光了,如:

response.write("alert('恭喜您,注册成功!'); "); response.redirect("main.html"); 这时候我们的提示内容没有出来就跳转了,和response.redirect("main.html"); 没有任何区别。

这时我们采用下面代码试验一下asp.net页面刷新:

response.write("alert('恭喜您,注册成功!')"); response.write("window.location.href='main.html'"); 这个即实现了我们的要求,在提示后,跳转页面。

最重要的是window.location.href 语句可以实现一个框架的页面在执行服务器端代码后刷新另一个框架的页面(response.redirect无法达到,至少我没有发现):

如:index.htm页面中有二个框架,分别为 frameleft和frameright,在frameright页面中执行服务器端代码后刷新frameleft中的页面。

先前最常见的是注册之后,自动刷新登陆框,让登陆框换成已登陆页面,只要在注册成功的代码之后加上一段,即可以实现刷新另个框架的页面。代码如下:

response.write("alert('恭喜您,注册成功!')"); response.write("window.parent.frameleft.location.href='main.html'"); asp.net页面刷新:自动刷新页面的实现方法总结:

1)

10表示间隔10秒刷新一次

2)

window.location.reload(true); 如果是你要刷新某一个iframe就把window给换成frame的名字或id号

3)

window.navigate("本页面url"); 4>

function abc() { window.location.href="/blog/window.location.href"; settimeout("abc()",10000); } 刷新本页:

response.write("window.location.href=window.location.href; ") 刷新父页:

response.write("opener.location.href=opener.location.href; ") 转到指定页:

response.write("window.location.href='yourpage.aspx'; ")
刷新页面实现方式总结(html,asp,网页特效)

'by aloxy

定时刷新:

1,

settimeout("location.href='url'",2000) 说明:url是要刷新的页面url地址

2000是等待时间=2秒,

2,

说明:

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,

说明:一般用一个url参数或者表单传值判断是否发生某个操作然后利用response.redirect 刷新。

4,刷新框架页

〈script language=javascript>top.leftfrm.location.reload(); parent.frmtop.location.reload();

response.write("window.showmodaldialog('../oa/spcl.aspx',window,'dialog dialog dialogtop: 200px; dialogleft: 133px')"); //open response.write("document.location=document.location; "); 在子窗体页面代码head中加入

刷新的内容加在 if (!ispostback) 中

在框架页中右面刷新左面

//刷新框架页左半部分 response.write(""); response.write("parent.left.location.href='paydetailmanage_left.aspx'"); response.write("");
页面定时刷新功能实现

有三种方法:

1,在html中设置:

xxxxx之後加入下面这一行即可!

定时刷新:

10代表刷新间隔,单位为秒

2.网页特效p/jsp.html target=_blank >jsp教程

每一秒刷新一次

3.使用javascript:

settimeout("self.location.reload(); ",1000); 一秒一次

页面自动跳转:

1,在html中设置:

xxxxx之後加入下面这一行即可!

定时跳转并刷新:

, 其中20指隔20秒后跳转到http://*自*??*?的url 页面。


点击按钮提交表单后刷新上级窗口

a窗口打开b窗口

然后在b里面提交数据至c窗口

最后要刷新a窗口

并且关闭b窗口

几个javascript函数

//第一个自动关闭窗口

0)settimeout("clock(); ",1000); else self.close(); } var i=2 clock(); //--> //第二个刷新父页面的函数

opener.location.reload(); //第三个打开窗口

function show(mylink,mytitle,width,height) {mailwin=window.open(mylink,mytitle,'top=350,left=460,,,scrollbars=no')} 有关asp.net页面刷新的问题,收藏这几种方法会有用的。

相关文章

精彩推荐