点按钮后5秒自动转向另一页面怎么弄
要求点按钮之后,先显示一panel,之后过5秒再转向。
private void Button1_Click(object sender, System.EventArgs e)
{
this.panel1.Visible=false;
this.panel2.Visible=true;
System.Threading.Thread.Sleep(5000);
Response.Redirect( "www.163.com ");
}
用这方法不会显示panel2,就转过去了
------解决方案--------------------只有使用javascript
------解决方案--------------------Page.RegisterClientScriptBlock( "turnTo ", "window.setTimeOut(\ "self.location.href= '你的网页 '\ ",5000));
大体上这样,未测试
------解决方案--------------------Page.RegisterClientScriptBlock( "turnTo ", " <script> window.setTimeOut(\ "self.location.href= '你的网页 '\ </script> ",5000));
------解决方案--------------------Response.Write( " <script> window.setTimeOut(self.location.href= 'http://www.163.com ',5000) </script> ");
没问题@!
------解决方案-------------------- <script> setTimeout(window.location= 'xxx.aspx ',5000); </script>
直接写在aspx文件中就可以了。
或者: Response.write( " <body onload=setTimeout(window.location= 'xxx.aspx ',5000);> </body> ");
------解决方案--------------------Thread.sleep(5000);
------解决方案--------------------js