user3121403
user3121403

Reputation: 133

What do I add to this timer to display it?

I am sorry for asking such a beginner question, but what do I add to display it on html?

DispatcherTimer timer1 = new DispatcherTimer();
    private void button1_Click(object sender, RoutedEventArgs e)
    {
        timer1.Interval = new TimeSpan(0, 0, 0, 1);
        timer1.Tick += new EventHandler(timer1_Tick);
        timer1.Start();
    }

    int tik = 60;
    void timer1_Tick(object sender, EventArgs e)
    {
        Countdown.Text = tik + " Seconds Remaining";
        if (tik > 0)
            tik--;
        else
            Countdown.Text = "Times Up";
    }

Upvotes: 0

Views: 78

Answers (1)

ElliotSchmelliot
ElliotSchmelliot

Reputation: 8392

Create a div or other container to store the String in your html. For example, in your html you might add:

<div id="time-text"></div>

And then in your js, probably within the Tick method, you might add:

jQuery:

$('#time-text').html(Countdown.Text);

or

Pure JavaScript:

document.getElementById('#time-text').innerHTML = Countdown.Text;

Upvotes: 1

Related Questions