Click here to Skip to main content
15,357,967 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I tried to make countdown timer in my webform but it not working. I try to go according this link: Using Timer on Examination Web page ASP.NET || C#.NET || Hindi - YouTube[^] He use C# I use VB. I would like to set timer on eg:60second and if time expire then click on button and set again timer to 60s and still arround. Can you help me please?

What I have tried:

<%@ Page Language="VB" Debug="true" validateRequest="false"  CodeFile="Monitoring.aspx.vb" Inherits="Monitoring"%>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
<body onload="startcountdown(20);" style="background-image:url('Image/obr.jpg');" >   
    function startCountdown(timeLeft) {
        var interval = setInterval( countdown, 1000 );

        function countdown() {
            if ( --timeLeft > 0 ) {
            } else {
                clearInterval( interval );
              //Show the alert message , change the message as per your need
              alert('Time Up!');

        function update() {
            hours   = Math.floor( timeLeft / 3600 );
            minutes = Math.floor( ( timeLeft % 3600 ) / 60 );
            seconds = timeLeft % 60;

            document.getElementById('lbltimer').innerHTML = '' + hours + ':' + minutes + ':' + seconds;

        function completed() {
          //Change the url here
            window.location = "";

    <form id="form2" runat="server">
Updated 28-Nov-21 23:21pm
Richard Deeming 24-Nov-21 3:40am
The choice of C# vs VB.NET is irrelevant - both of you are using Javascript, which is the only option for code that runs on the client.

You haven't explained what the problem is, nor what you have tried, nor where you are stuck.
Member 15251555 24-Nov-21 7:45am
Nothing happens at all, no timer is set on the label, as if the function was skipped.

function startCountdown(timeLeft) {
Javascript is case-sensitive. Your function is called startCountdown, but you try to call startcountdown.

If you check your browser's developer console, you will see an error telling you that the function startcountdown doesn't exist.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900