在回发期间,计时器值不应更改 [英] timer value should not change during postback
问题描述
我有两页(问题和结果)。,在第一页(问题)我显示问题的问题和选项...并通过按钮点击功能显示下一个问题(它获取下一个问题从数据库)...现在我想为整组问题添加计时器..计时器值减少到'0'它应该重定向到结果页面..我的问题是每当我点击下一个按钮显示下一个问题,计时器值是从原始值开始..我希望计时器从最后一个值继续而不是从初始值。帮助我
作为ASP.NET是无国籍的,它也不会维持计时器的状态。 :(
所以你需要实施状态管理技术。
以下是国家的例子使用ViewState进行管理:
protected void Page_Load( object sender,EventArgs e)
{
if (ViewState [ counter]!= null )
timer1.Interval =( int )ViewState [ < span class =code-string> counter];
else
{
timer1.Interval = < span class =code-digit> 30000 ; // 假设考试总时间为30 secs
ViewState [ countet] = 30000 ;
}
}
如果有,请随时提出疑问。 :)
我认为你可以使用AJAX来实现所需的功能。
请通过以下链接:
AJAX计时器 [ ^ ]
i have two page(question and result).,In first page(question) i''m displaying question and options for the question... and iam displaying the next question via button click function(it fetches the next qusetion from the database) ... now i want to add timer for the whole set of questions..once timer value decreses to ''0'' it should redirect to result page..my problem is whenever i clicks the next button to show next question the timer values is starting from original value.. i want the timer to continue from last value not from initial value..help me
As ASP.NET is stateless, it doesn''t maintain the state of timer as well. :(
So you need to implement State Management technique.
The following is the example of state management using ViewState:
protected void Page_Load(object sender, EventArgs e) { if(ViewState["counter"] != null) timer1.Interval = (int)ViewState["counter"]; else { timer1.Interval = 30000; // Assuming the total time of the exam is 30 secs ViewState["countet"]=30000; } }
Please feel free to ask any doubt if you have. :)
I think you can you can use AJAX to implement desired functionality.
Please go through this link :
AJAX Timer[^]
这篇关于在回发期间,计时器值不应更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!