如何创建一个在asp.net预订过程中工作的计时器? [英] How to create a timer which is working during a reservation process in asp.net ?
问题描述
我有一个预订酒店房间的网站。我想为这个过程安排一个30分钟的计时器。我的意思是当客户在多页中填写预订信息时,我有一个计时器来显示他允许完成预订的剩余时间。我想知道它是否可能以及如何?
提前感谢
I have a website for reserving hotel rooms. I want to put a 30 mins timer for this process . I mean while the customer is filling the information of reserve in MULTIPLE PAGES , I have a timer to show how much time is remained that he allowed to finish the reservation. I want to know if its possible and how ?
thanks in advance
推荐答案
当流程开始时,将会话时间存储在会话中
When the process starts, store the expiry time in the session
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Expiry"] == null)
{
Session["Expiry"] = DateTime.Now.AddMinutes(30);
}
}
使用一些javascript来显示每页的倒计时
asp.net中的倒数计时器 [ ^ ]
而不是对间隔进行硬编码,而不是从会话中存储的日期开始的分钟数
The use some javascript to show a countdown on each page
Countdown timer in asp.net[^]
Rather than hard-coding the interval you get the minutes left from the date stored in the session
var min = <%=(((DateTime)Session["Expiry"]) - DateTime.Now).Minutes %>;
这篇关于如何创建一个在asp.net预订过程中工作的计时器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!