<%@ Application Language="C#" %> <script runat="server"> void Application_Start(Object sender, EventArgs e) { // Code that runs on application startup Application["OnlineNow"] = 0; } void Application_End(Object sender, EventArgs e) { // Code that runs on application shutdown Application["OnlineNow"] = null; } void Application_Error(Object sender, EventArgs e) { // Code that runs when an unhandled error occurs } void Session_Start(Object sender, EventArgs e) { // Code that runs when a new session is started Application.Lock(); Application["OnlineNow"] = (int)Application["OnlineNow"] + 1; Application.UnLock(); } void Session_End(Object sender, EventArgs e) { Application.Lock(); Application["OnlineNow"] = (int)Application["OnlineNow"] - 1; Application.UnLock(); } </script>
<%@ Page Language="C#" Debug="true" %> <script runat="server"> void Page_Load(Object sender, EventArgs e) { this.lblText.Text = Application["OnlineNow"] + " Online"; } </script> <html> <head> <title>ThaiCreate.Com ASP.NET - Global.asax</title> </head> <body> <form id="form1" runat="server"> <asp:Label id="lblText" runat="server"></asp:Label><br /> </form> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท