I am facing a major issue with a simple task... I have an asp.net page with a Multiview containing two views.
In the first view, there is an ajax timer that counts down from 60 to 0. The time is displayed on a label within an updatepanel. I want to call a C# function that performs certain tasks and then switches to the next active view once the countdown reaches zero.
How can I achieve this?
I attempted to check in the Timer_tick event if the seconds reach 0 and called the function, but it did not work. I also tried setting Timer1.Enabled = false, but that didn't work either.
I believe I need to use JavaScript, but I am unfamiliar with how and where to implement it. I have no knowledge of Javascript yet.
This is my Timer_Tick event (The time displayed on the label functions properly)
protected void Timer1_Tick(object sender, EventArgs e)
{
Test t = (Test)Session["SelectedTest"];
if (t.Remaining.Minute == 0 && t.Remaining.Second == 0)
{
DoSomething();
}
else
{
t.Remaining= t.Remaining.AddSeconds(-1);
Label7.Text = t.Remaining.ToLongTimeString();
}
}
and my DoSomething() function:
public void DoSomething()
{
// Doing a lot of things....
MultiView1.ActiveViewIndex = 3;
}
The DoSomething function works correctly - I have a button that calls this function which also works. However, I want the function to be called when the remaining seconds reach 0 as well.