定时检查考试时间 [英] Timer to check time during exam

查看:68
本文介绍了定时检查考试时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个代码,用于在NN ASP.NET页面上放置一个计时器来检查在线编写考试时的时间。代码应该在Vb.net中。并且回发不应该重启计时器



SHOUTING删除 - OriginalGriff [/ edit]

解决方案

您好,



查看以下链接。

在asp.net显示计时器中倒计时器 [ ^ ]

倒数计时器在asp.net [ ^ ]

ASP.Net ,C#和Javascript倒计时器 [ ^ ]

如何使用C#在ASP.NET中生成CountDown计时器 [ ^ ]



希望有帮助


我们不做你的作业:它是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!


现在这就是我在Karthik给出的帮助下解决它的方式:



 受保护的  Sub  Timer1_Tick( ByVal 发​​件人作为 对象 ByVal  e  As  System.EventArgs)句柄 Timer1.Tick 

Dim timer_arr() As String
Dim timer As String
timer = Button1.Text

timer_arr = timer.Split(
会话( seconds)= Integer .Parse(timer_arr( 2 ))
Dim minutes = 整数 .Parse(timer_arr( 1 ))
Dim hours = 整数 .Parse(timer_arr( 0 ))
如果会话( seconds) = 0 minutes = 0 hours = 0 然后
Timer1.Enabled = 错误
其他
Session( seconds)= Session( ) - 1
结束 如果
如果(会话( seconds)< 0 然后
会话( )= 59
会话( minutes)=会话( 分钟) - 1
结束 如果
如果会话( 分钟)< 0 然后
会话( 分钟)= 59
会话( TimerRemaining)=会话( TimerRemaining) - 1
结束 如果

Button1.Text = Session( TimerRemaining)。ToString()& &会话( Minutes)。ToString& &会话( Seconds)。ToString

如果会话( TimerRemaining)= 0 会话( 分钟)= 0 会话( )= 0 然后
Button1.Enabled = False
Timer1.Enabled = False
结束 如果
结束 Sub







<前l ang =vb> 受保护的 Sub Page_Load( ByVal sender 作为 对象 ByVal e As System.EventArgs)句柄 .Load


如果 IsPostBack 然后
会话( TimerRemaining)= < span class =code-digit> 1
Session( Minutes)= 0
会话( )= 0
对接on1.Text = Session( TimerRemaining)。ToString()& &会话( Minutes)。ToString& &会话( Seconds)。ToString
结束 如果
结束 Sub







 <  表单    id   =  form1   < span class =code-attribute> runat   =  server >  

< div >
< asp:Script经理 ID = ScriptManager1 runat = server >
< / asp:ScriptManager >
< asp:UpdatePanel ID = UpdatePanel1 runat = 服务器 >
< ContentTemplate >
< span class =code-keyword>< asp:按钮 ID = Button1 runat = server 文字 = < span class =code-keyword>按钮 / >
< asp:Timer ID = Timer1 runat = server 时间间隔 = 1000 >
< / asp:Timer >
< / ContentTemplate >
< / asp:UpdatePanel >
< / div >


I need a code for putting a timer on aN ASP.NET page to check the time as you write an examination online. The code should be in Vb.net. And postback shouldn''t restart the timer

[edit]SHOUTING removed - OriginalGriff[/edit]

解决方案

Hi,

Check below links.
Count down timer in asp.net display timer[^]
Countdown timer in asp.net[^]
ASP.Net, C# and Javascript Count Down Timer[^]
How to make CountDown Timer in ASP.NET Using C#[^]

hope it helps


We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!


Now this is the way I solved it with the help given me above by Karthik:

Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick

       Dim timer_arr() As String
       Dim timer As String
       timer = Button1.Text

       timer_arr = timer.Split(":")
       Session("seconds") = Integer.Parse(timer_arr(2))
       Dim minutes = Integer.Parse(timer_arr(1))
       Dim hours = Integer.Parse(timer_arr(0))
       If Session("seconds") = 0 And minutes = 0 And hours = 0 Then
           Timer1.Enabled = False
       Else
           Session("seconds") = Session("seconds") - 1
       End If
       If (Session("seconds") < 0) Then
           Session("seconds") = 59
           Session("minutes") = Session("minutes") - 1
       End If
       If Session("minutes") < 0 Then
           Session("Minutes") = 59
           Session("TimerRemaining") = Session("TimerRemaining") - 1
       End If

       Button1.Text = Session("TimerRemaining").ToString() & ":" & Session("Minutes").ToString & ":" & Session("Seconds").ToString

       If Session("TimerRemaining") = 0 And Session("minutes") = 0 And Session("seconds") = 0 Then
           Button1.Enabled = False
           Timer1.Enabled = False
       End If
   End Sub




Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


        If Not IsPostBack Then
            Session("TimerRemaining") = 1
            Session("Minutes") = 0
            Session("Seconds") = 0
            Button1.Text = Session("TimerRemaining").ToString() & ":" & Session("Minutes").ToString & ":" & Session("Seconds").ToString
        End If
   End Sub




<form id="form1" runat="server">

                        <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Button ID="Button1" runat="server" Text="Button" />
                <asp:Timer ID="Timer1" runat="server" Interval="1000">
                </asp:Timer>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>


这篇关于定时检查考试时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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