如何保持在线观看 [英] how to maintain stop watch for on line

查看:85
本文介绍了如何保持在线观看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#在asp.net中下放了一个在线考试应用程序。我用了秒表。但是当我刷新页面时它重置..

我不想在页面刷新时重置秒表。请分享你的想法请帮帮我..

i devolved an on line exam application in asp.net with C#. I used stop watch. but it reset when i refresh page..
i don''t want to reset stop watch when page refresh. please share your idea please help me..

推荐答案

请看我对这个问题的评论:你错误地理解了问题的本质。你不能保留秒表,因为这是不同的实例,刷新后;整个应用程序再次执行。背景是:HTTP是无状态 http://en.wikipedia.org/wiki/HTTP [ ^ ]。



解决方案是将应用程序的中间状态保留在某个存储中,这是Web应用程序的主要问题之一,因此无论如何都需要学习它。请阅读有关会话状态管理和会话变量的信息: http:// msdn。 microsoft.com/en-us/library/ms178581%28v=vs.100%29.aspx [ ^ ]。



也许你应该更好地使用 System.DateTime ,而不是秒表。准确性不是很好,但足以满足您的目的(ms)。绝对日历时间为您提供绝对参考时间坐标系。您可以使用某个状态变量序列化记住的时间点并存储在会话状态中;刷新后,您可以通过读取状态变量来恢复记住的点。在轮询新的时间点现在后,您可以计算差异(使用为此类型定义的'' - ''运算符)。



-SA
Please see my comment to the question: you incorrectly understand the nature of your problem. You cannot keep the stopwatch, because this is not the same instance, after your refresh; the whole application is executed again. The background of this is: HTTP is stateless: http://en.wikipedia.org/wiki/HTTP[^].

The solution is keeping the intermediate state of your application in some storage, which is one of the main issues of Web applications, so you need to learn it anyway. Please read about session state management and session variables: http://msdn.microsoft.com/en-us/library/ms178581%28v=vs.100%29.aspx[^].

And perhaps you should better use System.DateTime, instead of stop watch. The accuracy is not so good, but good enough for your purpose (ms). The absolute calendar time gives you the absolute reference time coordinate system. You can serialized remembered point it time and store in session state using some state variable; after refresh, you can restore remembered point by reading the state variable. After polling new point of time Now, you can calculate the difference (using ''−'' operator defined for this type).

—SA






使用AJAX定时器控件.. 。



请查看这个....



http://www.ezineasp.net/post/ASP-Net-AJAX-Timer-Control.aspx [< a href =http://www.ezineasp.net/post/ASP-Net-AJAX-Timer-Control.aspxtarget =_ blanktitle =New Window> ^ ]


这篇关于如何保持在线观看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆