Вы находитесь на странице: 1из 4

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.

cs"
Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >


<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
&nbsp; &nbsp; &nbsp;<asp:ScriptManager ID="ScriptManager1"
runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
&nbsp;

<asp:Label ID="Label1" runat="server" Height="20px"


Style="z-index: 100; left: 13px;
position: absolute; top: 125px" Text="Label"
Width="141px"></asp:Label>
&nbsp;<br />

</ContentTemplate>

</asp:UpdatePanel>
<br />
<asp:Label ID="Label3" runat="server" Style="z-index: 100; left:
501px; position: absolute;
top: 53px" Text="Label"></asp:Label>
<br />
<br />
<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick1"
Interval="1000">
</asp:Timer>

</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page


{

protected void Page_Load(object sender, EventArgs e)


{

if (!IsPostBack)
{
Session["time"] = DateTime.Now.AddSeconds(10);
}

protected void Timer1_Tick1(object sender, EventArgs e)


{
Label3.Text = DateTime.Now.ToString();
TimeSpan time1 = new TimeSpan();
time1 = (DateTime)Session["time"] - DateTime.Now;
if (time1.Seconds <= 0)
{
Label1.Text = "TimeOut!";

}
else
{
Label1.Text = time1.Seconds.ToString();

}
}
/* no blink……*/

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="timer1.aspx.cs"


Inherits="timer1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >


<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer2" />
</Triggers>

</asp:UpdatePanel>

<asp:Label ID="Label1" runat="server" Font-Bold="true" Text="Time:"


Width="50px"></asp:Label>
<asp:TextBox ID="lbltiming" runat="server" BorderColor="White"
BorderStyle="Solid"
BorderWidth="1px" Font-
Bold="True" ForeColor="Red" Width="40px">1000000</asp:TextBox>
<asp:Label ID="Label2" runat="server" Font-Bold="true"
Text="Seconds" Width="55px"></asp:Label>

<script language= "JavaScript" type="text/javascript" >


var secs
var timerID = null
var timerRunning = false
var delay = 1000
InitializeTimer()
function InitializeTimer()
{
// Set the length of the timer, in seconds
secs =
document.getElementById('lblTiming').value
StopTheClock()
StartTheTimer()
}
function StopTheClock()
{
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}
function StartTheTimer()
{
if (secs==0)
{
StopTheClock()
}
else
{
document.getElementById('lblTiming').v
alue=secs;
secs = secs - 1
timerRunning = true
timerID =
self.setTimeout("StartTheTimer()", delay)
}
}

</script>

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;

<asp:Timer ID="Timer1" runat="server" Interval="1000">


</asp:Timer>
&nbsp;
<asp:Label ID="Label3" runat="server" Style="z-index: 100; left:
89px; position: absolute;
top: 262px" Text="Question ID"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Style="z-index: 101;
left: 182px; position: absolute;
top: 257px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Style="z-index: 107;
left: 320px; position: absolute; top: 490px" Text="Button" />
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:TextBox ID="TextBox2" runat="server" Style="z-index: 103;
left: 181px; position: absolute;
top: 304px"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server" Style="z-index: 104;
left: 182px; position: absolute;
top: 352px"></asp:TextBox>
<asp:Label ID="Label4" runat="server" Style="z-index: 105; left:
90px; position: absolute;
top: 306px" Text="Question"></asp:Label>
<asp:Label ID="Label5" runat="server" Style="z-index: 106; left:
89px; position: absolute;
top: 354px" Text="Difficulty level"></asp:Label>

</div>
</form>
</body>
</html>

Оценить