Live Chat Icon For mobile
Live Chat Icon

How can I use a Timer Control to refresh a page automatically at a specified interval

Platform: ASP.NET| Category: Client Side Scripting

<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>

<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>

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.