473,663 Members | 2,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("Us erCount")

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("Us erCount") in UNLOAD or DISPOSE I get a
spoky reaction in Application("Us erCount") - 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 2813
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******** ******@tk2msftn gp13.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("Us erCount")

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("Us erCount") in UNLOAD or DISPOSE I get a
spoky reaction in Application("Us erCount") - 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**@tienonsoft ware.com

"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message news:eQ******** ******@TK2MSFTN GP11.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******** ******@tk2msftn gp13.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("Us erCount")

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("Us erCount") in UNLOAD or DISPOSE I get a
spoky reaction in Application("Us erCount") - 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.ne t> skrev i en meddelelse
news:eQ******** ******@TK2MSFTN GP11.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(ByV al sender As Object, ByVal e As EventArgs)
' Fires when the session ends
If CType(Session(" UserName"), String) <> "" OrElse Not
(Session("UserN ame") Is Nothing) Then
Application("Al lUsers") = CType(Applicati on("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 ArgumentExcepti on(

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

}

if (control.Page.R equest.Browser. JavaScript == true)

{

// Create JavaScript

StringBuilder s = new StringBuilder() ;

s.Append("\n<SC RIPT LANGUAGE='JavaS cript'>\n");

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

s.Append("funct ion SetInitialFocus ()\n");

s.Append("{\n") ;

s.Append(" document.");

// Find the Form

System.Web.UI.C ontrol p = control.Parent;

while (!(p is System.Web.UI.H tmlControls.Htm lForm))

p = p.Parent;

s.Append(p.Clie ntID);

s.Append("['");

s.Append(contro l.UniqueID);

// Set Focus on the selected item of a RadioButtonList

System.Web.UI.W ebControls.Text Box rbl = control as
System.Web.UI.W ebControls.Text Box;

s.Append("'].focus();\n document.all.Wa itState.style.d isplay = 'None';\n");

s.Append("}\n") ;

if (control.Page.S martNavigation)

s.Append("windo w.setTimeout(Se tInitialFocus, 500);\n");

else

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

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

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

// Register Client Script

control.Page.Re gisterClientScr iptBlock("Initi alFocus", 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******** ********@TK2MSF TNGP11.phx.gbl. ..

"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> skrev i en meddelelse
news:eQ******** ******@TK2MSFTN GP11.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(ByV al sender As Object, ByVal e As EventArgs)
' Fires when the session ends
If CType(Session(" UserName"), String) <> "" OrElse Not
(Session("UserN ame") Is Nothing) Then
Application("Al lUsers") = CType(Applicati on("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>.Foc us

as in Windows Forms ?

KS, Denmark

"Alvin Bruney [MVP]" <vapor at steaming post office> skrev i en meddelelse
news:%2******** ********@TK2MSF TNGP10.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 ArgumentExcepti on(

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

}

if (control.Page.R equest.Browser. JavaScript == true)

{

// Create JavaScript

StringBuilder s = new StringBuilder() ;

s.Append("\n<SC RIPT LANGUAGE='JavaS cript'>\n");

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

s.Append("funct ion SetInitialFocus ()\n");

s.Append("{\n") ;

s.Append(" document.");

// Find the Form

System.Web.UI.C ontrol p = control.Parent;

while (!(p is System.Web.UI.H tmlControls.Htm lForm))

p = p.Parent;

s.Append(p.Clie ntID);

s.Append("['");

s.Append(contro l.UniqueID);

// Set Focus on the selected item of a RadioButtonList

System.Web.UI.W ebControls.Text Box rbl = control as
System.Web.UI.W ebControls.Text Box;

s.Append("'].focus();\n document.all.Wa itState.style.d isplay =

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

if (control.Page.S martNavigation)

s.Append("windo w.setTimeout(Se tInitialFocus, 500);\n");

else

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

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

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

// Register Client Script

control.Page.Re gisterClientScr iptBlock("Initi alFocus", 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******** ********@TK2MSF TNGP11.phx.gbl. ..

"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> skrev i en meddelelse
news:eQ******** ******@TK2MSFTN GP11.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(ByV al sender As Object, ByVal e As EventArgs)
' Fires when the session ends
If CType(Session(" UserName"), String) <> "" OrElse Not
(Session("UserN ame") Is Nothing) Then
Application("Al lUsers") = CType(Applicati on("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.C ontrol)

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

RegisterStartup Script("focus", s)

End Sub

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

Why not just

<controlID>.Foc us

as in Windows Forms ?

KS, Denmark

"Alvin Bruney [MVP]" <vapor at steaming post office> skrev i en meddelelse
news:%2******** ********@TK2MSF TNGP10.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 ArgumentExcepti on(

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

}

if (control.Page.R equest.Browser. JavaScript == true)

{

// Create JavaScript

StringBuilder s = new StringBuilder() ;

s.Append("\n<SC RIPT LANGUAGE='JavaS cript'>\n");

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

s.Append("funct ion SetInitialFocus ()\n");

s.Append("{\n") ;

s.Append(" document.");

// Find the Form

System.Web.UI.C ontrol p = control.Parent;

while (!(p is System.Web.UI.H tmlControls.Htm lForm))

p = p.Parent;

s.Append(p.Clie ntID);

s.Append("['");

s.Append(contro l.UniqueID);

// Set Focus on the selected item of a RadioButtonList

System.Web.UI.W ebControls.Text Box rbl = control as
System.Web.UI.W ebControls.Text Box;

s.Append("'].focus();\n document.all.Wa itState.style.d isplay =

'None';\n");

s.Append("}\n") ;

if (control.Page.S martNavigation)

s.Append("windo w.setTimeout(Se tInitialFocus, 500);\n");

else

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

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

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

// Register Client Script

control.Page.Re gisterClientScr iptBlock("Initi alFocus", 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******** ********@TK2MSF TNGP11.phx.gbl. ..

"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> skrev i en meddelelse
news:eQ******** ******@TK2MSFTN GP11.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(ByV al sender As Object, ByVal e As EventArgs)
' Fires when the session ends
If CType(Session(" UserName"), String) <> "" OrElse Not
(Session("UserN ame") Is Nothing) Then
Application("Al lUsers") = CType(Applicati on("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
546
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.] System.Data.DataView.GetElement(Int32 index) +43 System.Data.DataView.get_Item(Int32 recordIndex) +5 afgprojekt.Delete_external_user.bnDelExtUser_Click(Object sender,
5
5686
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 information at this point so I am also going to post this in a MySQL related group. I will create some designs and post back to the group if I get any feedback I can use. Problem: I would like to be able to keep a running percentage total in...
3
7795
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 same query with a count(*) to know how many pages I will get (number total of rows/ X). The problem is my query is very slow (maybe 5s) because there is much
7
12067
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 to know this number after the first FETCH, isn't it? On a side note, why queries using LIMIT are SO terribly slow, compared to cursors and sometimes even ones without LIMIT? Shouldn't LIMIT be internally implemented using cursor mechanism then?...
0
1363
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 categories in that field and a total record count for the db. Now, I need to add another "total database" grouping to get another set of record counts. I DO NOT want to nest this group, It MUST consider ALL database records.
2
35885
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 write the correct expression due to the "groupby" needed to group the city count in the first column. Any clues?
2
3079
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 have same value = 1 ( which may not be the case ) I need to create a FIFO queue in which at any given time I need the total element value = 10. ( not the size of array ). say if the data stream is all 1 e.g. 1,1,1,1,1,1,1,1,1
2
6963
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: <asp:DataGrid AllowCustomPaging="false" AllowPaging="true" AllowSorting="true"
3
16429
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 pages (10 records per page) and 98 records total, Rows.Count will return me 10 on the first 9 pages, and 8, on the last page. But, I need to somehow get access to total record count which is 98. What is the proper/easy way to accomplish that?
3
9813
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 out which was the faster way or more efficient way. I originally thought about getting SQL to do it, but that would entail either a second Select or some type of subquery or self join, which I am not sure is the best way.
0
8436
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8858
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8548
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8634
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5657
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4182
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.