all groups > asp.net > january 2004 >
You're in the

asp.net

group:

Total user count in Web-application


Re: Total user count in Web-application Steve C. Orr [MVP, MCSD]
1/31/2004 3:10:45 PM
asp.net: 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


[quoted text, click to view]

Total user count in Web-application KS
1/31/2004 11:53:48 PM
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


Re: Total user count in Web-application KS
2/1/2004 9:55:39 AM

"Steve C. Orr [MVP, MCSD]" <Steve@Orr.net> skrev i en meddelelse
news:eQYU39E6DHA.2392@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view]
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

Re: Total user count in Web-application Do Quyet Tien
2/1/2004 10:15:23 AM
And mean that your counter only updated when the session timed-out :), =
again, no better way at this time.

Tiendq,
tien@tienonsoftware.com

[quoted text, click to view]
Re: Total user count in Web-application Alvin Bruney [MVP]
2/1/2004 8:55:58 PM
[quoted text, click to view]
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("InitialFocus", s.ToString());

}

}


--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
[quoted text, click to view]

Re: Total user count in Web-application KS
2/2/2004 7:36:47 AM
!!!!!!!!!! - "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:%23uM4WgT6DHA.2044@TK2MSFTNGP10.phx.gbl...
[quoted text, click to view]

Re: Total user count in Web-application (& SetFocus) George
2/2/2004 9:03:55 AM
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


[quoted text, click to view]


AddThis Social Bookmark Button