请问 想做个考试倒计时提示浮动窗口的形式,该如何实现呢?
浮动窗口怎么做呢?
还有 我现在做了个asp页面 但是页面中的viewstate不起作用,为什么?
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lbTime" runat="server"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick">
</asp:Timer>
</div>
cs文件
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
ViewState["Test"] =90 * 60;
}
protected void Timer1_Tick(object sender, EventArgs e)
{
totalMS = Convert.ToDouble(ViewState["Test"]);
totalMS = totalMS - 1;
ViewState["Test"] = totalMS;
totalMin = (int)(totalMS / 60);
totalSec = (int)(totalMS - totalMin * 60);
lbTime.Text = "The rest time is:" + Convert.ToString(totalMin) + ":" + Convert.ToString(totalSec);
}
为什么每次刷新都重新倒计时呢?不明白 望高手解答
浮动窗口怎么做呢?
还有 我现在做了个asp页面 但是页面中的viewstate不起作用,为什么?
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lbTime" runat="server"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick">
</asp:Timer>
</div>
cs文件
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
ViewState["Test"] =90 * 60;
}
protected void Timer1_Tick(object sender, EventArgs e)
{
totalMS = Convert.ToDouble(ViewState["Test"]);
totalMS = totalMS - 1;
ViewState["Test"] = totalMS;
totalMin = (int)(totalMS / 60);
totalSec = (int)(totalMS - totalMin * 60);
lbTime.Text = "The rest time is:" + Convert.ToString(totalMin) + ":" + Convert.ToString(totalSec);
}
为什么每次刷新都重新倒计时呢?不明白 望高手解答
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货