【发布时间】:2013-03-22 22:30:35
【问题描述】:
我在简单的任务中遇到了大问题...在 asp.net 页面上是具有两个视图的 Multiview,
在第一个视图中,我有 ajax 计时器,它从 60 到 0 计数秒。时间显示在标签上,在更新面板中。我会调用我的 c# 函数来做一些事情并最终改变活动视图。
我该怎么做?
我尝试检查 Timer_tick 事件,如果秒 == 0,我调用函数,但它不起作用。 我也试过 Timer1.Enabled = false,但它也不起作用。
我认为,我必须使用 Javascript,但如何?我不知道在哪里以及如何...我还不知道 Javascript。
这是我的 Timer_Tick 事件(标签上的时间显示正确)
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();
}
}
还有我的 DoSomething() 函数:
public void DoSomething()
{
// Doing a lot of things....
MultiView1.ActiveViewIndex = 3;
}
Function Dosomething 正常工作,我也有按钮调用此函数 - 它正在工作但如果剩余秒数 == 0,我也想调用函数。
【问题讨论】:
-
你试过
if (t.Remaining.Minute <= 0 && t.Remaining.Second <= 0)吗?
标签: c# javascript asp.net ajax timer