关于Asp.net页面的刷新
在Asp.net中,当你点击button或者将gridview进行分页,点击页面的时候,它们都会进行页面刷新,或者进行postback。
有的时候我们需要设置checkbox按钮,比如全选,当选择它的时候使前台整个页面进行刷新,这个时候一定要将对应控件的autopostback 属性设置为true
举例如下(当点击全选的时候,前台页面要进行刷新,使其他复选框都置为选择状态。这个时候主要要将checkbox的autopostback属性设置为true,然后对应填入事件响应函数即可):
其他后台代码手动刷新页面的方法,这些方法摘自http://www.cnblogs.com/raymond19840709/archive/2007/09/11/890045.html
第一:
private void Button1_Click( object sender, System.EventArgs e )
{
Response.Redirect( Request.Url.ToString( ) );
}
第二:
private void Button2_Click( object sender, System.EventArgs e )
{
Response.Write( "
<script language=javascript>window.location.href=document.URL;
</script>" );
}
第三:
private void Button3_Click( object sender, System.EventArgs e )
{
Response.AddHeader( "Refresh","0" );
}
第四:
private void Button6_Click( object sender, System.EventArgs e )
{
Response.Write( "
<script language=javascript>window.location.reload( );
</script>" );
}
第五:(需替换<>)
<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 font-family: georgia, verdana, Arial, helvetica, sans-seriff; font-size: 13px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 20px; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">LEFT: 408px;
POSITION: absolute;
TOP: 232px" ms_positioning="text2D">
<P><FONT size="3">自动刷新页面</FONT></P>
</DIV>
private void Button1_Click( object sender, System.EventArgs e )
{
Response.Redirect( Request.Url.ToString( ) );
}
第二:
private void Button2_Click( object sender, System.EventArgs e )
{
Response.Write( "
<script language=javascript>window.location.href=document.URL;
</script>" );
}
第三:
private void Button3_Click( object sender, System.EventArgs e )
{
Response.AddHeader( "Refresh","0" );
}
第四:
private void Button6_Click( object sender, System.EventArgs e )
{
Response.Write( "
<script language=javascript>window.location.reload( );
</script>" );
}
第五:(需替换<>)
<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 font-family: georgia, verdana, Arial, helvetica, sans-seriff; font-size: 13px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 20px; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">LEFT: 408px;
POSITION: absolute;
TOP: 232px" ms_positioning="text2D">
<P><FONT size="3">自动刷新页面</FONT></P>
</DIV>
第六:
<meta http-equiv="refresh" content="300; url=target.html">
<meta http-equiv="refresh" content="300; url=target.html">