Ayyappan Anbalagan
Ayyappan Anbalagan

Reputation: 11302

how to refresh the asp.net Label every second automatically using Java script instead ajax?

how to refresh the asp.net Label every second automatically using Java script instead ajax?

Upvotes: 0

Views: 2783

Answers (1)

Willem
Willem

Reputation: 5404

ajax is javascript in combination with a webrequest, so if you don't want to use ajax but only javascript the data has to come from somewhere else...

Put this at the end of your page and replace Label1 with the name of your Label for a nice working digital clock:

<script type="text/javascript">
function updateLabel(){
    document.getElementById('<%= Label1.ClientID %>').innerHTML = new Date(); 
    // replace new Date() with your updated value
    setTimeout("updateLabel()",1000);
}
updateLabel();
</script>

Upvotes: 1

Related Questions