473,385 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Total user count in Web-application

KS
I have made a WebForm with log ON/OFF off users.

There is a label that shows the total count off users logged on stored in
Application("UserCount")

It works fine if the users logs out WITH THE LOG-OUT BUTTON, but what if a
user "logs out" by closing with the X-button ?

If I count down the Application("UserCount") in UNLOAD or DISPOSE I get a
spoky reaction in Application("UserCount") - it just counts wrong !

What can I do to catch (and count down the total users) that a user "logs
out" by using the X-button ?

KS, Denmark

Nov 18 '05 #1
6 2796
You can use a counter in your Global.asax, in the Session_Start and
Session_End events to get a rough idea of how many people are on your site.
There is no good way to get a real-time precise count, however, due to the
stateless nature of the internet.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"KS" <ke************@os.dk> wrote in message
news:OD**************@tk2msftngp13.phx.gbl...
I have made a WebForm with log ON/OFF off users.

There is a label that shows the total count off users logged on stored in
Application("UserCount")

It works fine if the users logs out WITH THE LOG-OUT BUTTON, but what if a
user "logs out" by closing with the X-button ?

If I count down the Application("UserCount") in UNLOAD or DISPOSE I get a
spoky reaction in Application("UserCount") - it just counts wrong !

What can I do to catch (and count down the total users) that a user "logs
out" by using the X-button ?

KS, Denmark

Nov 18 '05 #2
And mean that your counter only updated when the session timed-out :), again, no better way at this time.

Tiendq,
ti**@tienonsoftware.com

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message news:eQ**************@TK2MSFTNGP11.phx.gbl...
You can use a counter in your Global.asax, in the Session_Start and
Session_End events to get a rough idea of how many people are on your site.
There is no good way to get a real-time precise count, however, due to the
stateless nature of the internet.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


"KS" <ke************@os.dk> wrote in message
news:OD**************@tk2msftngp13.phx.gbl...
I have made a WebForm with log ON/OFF off users.

There is a label that shows the total count off users logged on stored in
Application("UserCount")

It works fine if the users logs out WITH THE LOG-OUT BUTTON, but what if a
user "logs out" by closing with the X-button ?

If I count down the Application("UserCount") in UNLOAD or DISPOSE I get a
spoky reaction in Application("UserCount") - it just counts wrong !

What can I do to catch (and count down the total users) that a user "logs
out" by using the X-button ?

KS, Denmark


Nov 18 '05 #3
KS

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> skrev i en meddelelse
news:eQ**************@TK2MSFTNGP11.phx.gbl...
You can use a counter in your Global.asax, in the Session_Start and
Session_End events to get a rough idea of how many people are on your site. There is no good way to get a real-time precise count, however, due to the
stateless nature of the internet.

I seems as though my code in Global.asax Session_End is NOT executed.

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
If CType(Session("UserName"), String) <> "" OrElse Not
(Session("UserName") Is Nothing) Then
Application("AllUsers") = CType(Application("AllUsers"), Integer) - 1
End If
End Sub

IS the sub Session_End REALLY fired when the user closes using the
X-button - how can I make shure ?
(a break-point somewhere in the Session_End will NOT do it !)

Should I addhandler or what ?

Another thing - How can I set focus in a textbox at a webform ?

KS, Denmark
Nov 18 '05 #4
> Another thing - How can I set focus in a textbox at a webform ?
i use this code generically.

public static void SetInitialFocus(System.Web.UI.Control control)

{

if (control.Page == null)

{

throw new ArgumentException(

"The Control must be added to a Page before you can set the IntialFocus to
it.");

}

if (control.Page.Request.Browser.JavaScript == true)

{

// Create JavaScript

StringBuilder s = new StringBuilder();

s.Append("\n<SCRIPT LANGUAGE='JavaScript'>\n");

s.Append("<!--\n");

s.Append("function SetInitialFocus()\n");

s.Append("{\n");

s.Append(" document.");

// Find the Form

System.Web.UI.Control p = control.Parent;

while (!(p is System.Web.UI.HtmlControls.HtmlForm))

p = p.Parent;

s.Append(p.ClientID);

s.Append("['");

s.Append(control.UniqueID);

// Set Focus on the selected item of a RadioButtonList

System.Web.UI.WebControls.TextBox rbl = control as
System.Web.UI.WebControls.TextBox;

s.Append("'].focus();\n document.all.WaitState.style.display = 'None';\n");

s.Append("}\n");

if (control.Page.SmartNavigation)

s.Append("window.setTimeout(SetInitialFocus, 500);\n");

else

s.Append("window.onload = SetInitialFocus;\n");

s.Append("// -->\n");

s.Append("</SCRIPT>");

// Register Client Script

control.Page.RegisterClientScriptBlock("InitialFoc us", s.ToString());

}

}
--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"KS" <ke************@os.dk> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> skrev i en meddelelse
news:eQ**************@TK2MSFTNGP11.phx.gbl...
You can use a counter in your Global.asax, in the Session_Start and
Session_End events to get a rough idea of how many people are on your

site.
There is no good way to get a real-time precise count, however, due to the stateless nature of the internet.

I seems as though my code in Global.asax Session_End is NOT executed.

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
If CType(Session("UserName"), String) <> "" OrElse Not
(Session("UserName") Is Nothing) Then
Application("AllUsers") = CType(Application("AllUsers"), Integer) - 1
End If
End Sub

IS the sub Session_End REALLY fired when the user closes using the
X-button - how can I make shure ?
(a break-point somewhere in the Session_End will NOT do it !)

Should I addhandler or what ?

Another thing - How can I set focus in a textbox at a webform ?

KS, Denmark

Nov 18 '05 #5
KS
!!!!!!!!!! - "aahh - peace og cake !" ;-(

Why not just

<controlID>.Focus

as in Windows Forms ?

KS, Denmark

"Alvin Bruney [MVP]" <vapor at steaming post office> skrev i en meddelelse
news:%2****************@TK2MSFTNGP10.phx.gbl...
Another thing - How can I set focus in a textbox at a webform ? i use this code generically.

public static void SetInitialFocus(System.Web.UI.Control control)

{

if (control.Page == null)

{

throw new ArgumentException(

"The Control must be added to a Page before you can set the IntialFocus to
it.");

}

if (control.Page.Request.Browser.JavaScript == true)

{

// Create JavaScript

StringBuilder s = new StringBuilder();

s.Append("\n<SCRIPT LANGUAGE='JavaScript'>\n");

s.Append("<!--\n");

s.Append("function SetInitialFocus()\n");

s.Append("{\n");

s.Append(" document.");

// Find the Form

System.Web.UI.Control p = control.Parent;

while (!(p is System.Web.UI.HtmlControls.HtmlForm))

p = p.Parent;

s.Append(p.ClientID);

s.Append("['");

s.Append(control.UniqueID);

// Set Focus on the selected item of a RadioButtonList

System.Web.UI.WebControls.TextBox rbl = control as
System.Web.UI.WebControls.TextBox;

s.Append("'].focus();\n document.all.WaitState.style.display =

'None';\n");
s.Append("}\n");

if (control.Page.SmartNavigation)

s.Append("window.setTimeout(SetInitialFocus, 500);\n");

else

s.Append("window.onload = SetInitialFocus;\n");

s.Append("// -->\n");

s.Append("</SCRIPT>");

// Register Client Script

control.Page.RegisterClientScriptBlock("InitialFoc us", s.ToString());

}

}
--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"KS" <ke************@os.dk> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> skrev i en meddelelse
news:eQ**************@TK2MSFTNGP11.phx.gbl...
You can use a counter in your Global.asax, in the Session_Start and
Session_End events to get a rough idea of how many people are on your

site.
There is no good way to get a real-time precise count, however, due to the stateless nature of the internet.

I seems as though my code in Global.asax Session_End is NOT executed.

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
If CType(Session("UserName"), String) <> "" OrElse Not
(Session("UserName") Is Nothing) Then
Application("AllUsers") = CType(Application("AllUsers"), Integer) - 1 End If
End Sub

IS the sub Session_End REALLY fired when the user closes using the
X-button - how can I make shure ?
(a break-point somewhere in the Session_End will NOT do it !)

Should I addhandler or what ?

Another thing - How can I set focus in a textbox at a webform ?

KS, Denmark


Nov 18 '05 #6
Here's something I found on the Web that I have been using.

Private Sub SetFocus(ByVal ctrl As System.Web.UI.Control)

Dim s As String = "<SCRIPT language='javascript'>document.getElementById('"
& ctrl.ID & "').focus() </SCRIPT>"

RegisterStartupScript("focus", s)

End Sub

George
"KS" <ke************@os.dk> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
!!!!!!!!!! - "aahh - peace og cake !" ;-(

Why not just

<controlID>.Focus

as in Windows Forms ?

KS, Denmark

"Alvin Bruney [MVP]" <vapor at steaming post office> skrev i en meddelelse
news:%2****************@TK2MSFTNGP10.phx.gbl...
Another thing - How can I set focus in a textbox at a webform ? i use this code generically.

public static void SetInitialFocus(System.Web.UI.Control control)

{

if (control.Page == null)

{

throw new ArgumentException(

"The Control must be added to a Page before you can set the IntialFocus to
it.");

}

if (control.Page.Request.Browser.JavaScript == true)

{

// Create JavaScript

StringBuilder s = new StringBuilder();

s.Append("\n<SCRIPT LANGUAGE='JavaScript'>\n");

s.Append("<!--\n");

s.Append("function SetInitialFocus()\n");

s.Append("{\n");

s.Append(" document.");

// Find the Form

System.Web.UI.Control p = control.Parent;

while (!(p is System.Web.UI.HtmlControls.HtmlForm))

p = p.Parent;

s.Append(p.ClientID);

s.Append("['");

s.Append(control.UniqueID);

// Set Focus on the selected item of a RadioButtonList

System.Web.UI.WebControls.TextBox rbl = control as
System.Web.UI.WebControls.TextBox;

s.Append("'].focus();\n document.all.WaitState.style.display =

'None';\n");

s.Append("}\n");

if (control.Page.SmartNavigation)

s.Append("window.setTimeout(SetInitialFocus, 500);\n");

else

s.Append("window.onload = SetInitialFocus;\n");

s.Append("// -->\n");

s.Append("</SCRIPT>");

// Register Client Script

control.Page.RegisterClientScriptBlock("InitialFoc us", s.ToString());

}

}
--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"KS" <ke************@os.dk> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> skrev i en meddelelse
news:eQ**************@TK2MSFTNGP11.phx.gbl...
> You can use a counter in your Global.asax, in the Session_Start and
> Session_End events to get a rough idea of how many people are on your site.
> There is no good way to get a real-time precise count, however, due
to the
> stateless nature of the internet.
>
I seems as though my code in Global.asax Session_End is NOT executed.

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
If CType(Session("UserName"), String) <> "" OrElse Not
(Session("UserName") Is Nothing) Then
Application("AllUsers") = CType(Application("AllUsers"),

Integer) - 1 End If
End Sub

IS the sub Session_End REALLY fired when the user closes using the
X-button - how can I make shure ?
(a break-point somewhere in the Session_End will NOT do it !)

Should I addhandler or what ?

Another thing - How can I set focus in a textbox at a webform ?

KS, Denmark




Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: clauschc | last post by:
Hi, When my web page returning no data I got a unhandled exception. How can I handel this error? IndexOutOfRangeException: Index 0 is not non-negative and below total rows count.]...
5
by: fwells11 | last post by:
Hi there. As you will see from my questions, I am an SQL newb. I dabble but never get to spend enough time to get proficient so base any feeedback on that basis please. This is all theoretical...
3
by: krystoffff | last post by:
Hi I would like to paginate the results of a query on several pages. So I use a query with a limit X offset Y to display X results on a page, ok. But for the first page, I need to run the...
7
by: Egor Shipovalov | last post by:
I'm implementing paging through search results using cursors. Is there a better way to know total number of rows under a cursor than running a separate COUNT(*) query? I think PostgreSQL is bound...
0
by: Richard Holliingsworth | last post by:
Hello: I'm building a report to display statistics on the entire database. I have successfully built a report that groups the entire db on one field and gives me a count of db records for the...
2
by: mhodkin | last post by:
I created a query in which I have grouped data by City. I wish to calculate the percent of each value, e.g. City/(Total count of all Cities), in tbe next column of the query. I can't seem to...
2
by: worli | last post by:
Hi All, I have a strange requirement. I have a dynamic input numeric data stream e.g. 2, 2, 4, 5 etc.... ( each input number range from 1 to 10 ). lets take a simple case where all inputs will...
2
by: DC Gringo | last post by:
I have a datagrid control that has paging set up and working. What I would like is a total record count (not just per page) in the header or near the header of the datagrid. Here's my code: ...
3
by: Amelyan | last post by:
I need to get the total number of items/records returned into GridView. If I just do myGridView.Rows.Count, then it just returns me the total number of items on the page. But if I have, 10...
3
by: tshad | last post by:
I am building a GridView that is displaying some money values in 3 columns. I want to put the totals of each column in a label field (one for each column) in the footer. I was trying to figure...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.