How can I use a Timer Control to refresh a page automatically at a specified interval?
<asp:DropDownList id="DropDownList1" runat="server" onChange="SetClientRefresh(this);">
<asp:ListItem Value="1000">1 second</asp:ListItem>
<asp:ListItem Value="2000">2 seconds</asp:ListItem>
<asp:ListItem Value="3000">3 seconds</asp:ListItem>
</asp:DropDownList>
<asp:ListItem Value="1000">1 second</asp:ListItem>
<asp:ListItem Value="2000">2 seconds</asp:ListItem>
<asp:ListItem Value="3000">3 seconds</asp:ListItem>
</asp:DropDownList>
<script language='javascript'>
var cTimeOut = null;
function SetClientRefresh(sel)
{
var newRefresh = sel.options[sel.selectedIndex].value;
if (cTimeOut != null)
{
window.clearTimeout(cTimeOut);
}
cTimeOut = window.setTimeout("ReLoadPage()", newRefresh);
}
function ReLoadPage()
{
window.location.reload();
}
</script>
{
window.location.reload();
}
</script>
No comments:
Post a Comment