作者Astroboy0803 (Drucker)
站内Visual_Basic
标题[.NET] 显示20分钟内线上的人数
时间Mon May 14 20:40:09 2007
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Page.Title = "7-3"
Session.Timeout = 1
If Session("population") Is Nothing Then
Session("population") = 1
Else
Session("population") += 1
End If
Session.Timeout = 20
End Sub
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs)
Label1.Text = Label1.Text & Session("population")
End Sub
如果是用session写的话,那麽ie一关就又变成1了,所以我改用application写,如下
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Page.Title = "7-3"
Session.Timeout = 20
If Application("population") Is Nothing Then
Application("population") = 1
Session("population") = Application("population")
Else
Application("population") += 1
Session("population") = Application("population")
End If
End Sub
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs)
Label1.Text = Label1.Text & Session("population")
End Sub
这样写的话,是没办法将时间控制在20分钟内,人数会一直增加,不知道我该改那里呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.123.1.3