473,378 Members | 1,479 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,378 software developers and data experts.

Finding out the time user takes before hitting submit

Hi,

I was wondering how I can find out the time user takes on an aspx page
before hitting a submit button. Since there is that whole server-side
vs. client-side issue, I was thinking I can store the current time in
a variable on server side, and when the user hits submit, inside the
method invoked I take the difference of the time now and the
previously stored time.

It all makes sense right? And I'm new with ASP.NET coding, so I'd
appreciate if someone can show me a little bit of code so I know which
libraries to use and the syntax.

Thank you in advance.

Asad
Nov 18 '05 #1
3 1139
On 26 Apr 2004 16:36:32 -0700, as*******@hotmail.com (Asad) wrote:
I was wondering how I can find out the time user takes on an aspx page
before hitting a submit button. Since there is that whole server-side
vs. client-side issue, I was thinking I can store the current time in
a variable on server side, and when the user hits submit, inside the
method invoked I take the difference of the time now and the
previously stored time.


Your point of server / client side is good and would lead me to do the
timing on the client side. If you are testing how long a user is
looking at a page, it would be unfair to count the download and
tranfer times. Using Javascript, set a variable on pageload and on
submit, determine the time between now and the saved time. Pass that
value back to the server for processing and recording.

Nov 18 '05 #2
Hi Asad,

If you want to do it on the server-side, you could set the time when the
page loads and store it in a viewstate. Then, when the postback happens (the
user clicked the button), you can calculate the time of the postback minus
the original time. All this is done in a TimeSpan.

Here's the idea:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
If Not IsPostBack Then
viewstate("starttime") = Now
Else
Dim tmspan As TimeSpan
tmspan = Date.Now.Subtract _
(CType(viewstate("starttime"), DateTime))
Label1.Text = tmspan.TotalSeconds.ToString
End If
End Sub

<form id="Form1" method="post" runat="server">
<P>
<asp:Label id="Label1" runat="server">Label</asp:Label></P>
<P>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></P>
</form>

Does this help?

Ken
Microsoft MVP [ASP.NET]
Toronto

"Asad" <as*******@hotmail.com> wrote in message
news:fd**************************@posting.google.c om...
Hi,

I was wondering how I can find out the time user takes on an aspx page
before hitting a submit button. Since there is that whole server-side
vs. client-side issue, I was thinking I can store the current time in
a variable on server side, and when the user hits submit, inside the
method invoked I take the difference of the time now and the
previously stored time.

It all makes sense right? And I'm new with ASP.NET coding, so I'd
appreciate if someone can show me a little bit of code so I know which
libraries to use and the syntax.

Thank you in advance.

Asad


Nov 18 '05 #3
One way to do it in concept (code not sure)

have a hidden input box on the form.

on the onload event fire some javascript that updates this input box each
second.

then when the form is submitted you simply check the value in that box.

"Asad" <as*******@hotmail.com> wrote in message
news:fd**************************@posting.google.c om...
Hi,

I was wondering how I can find out the time user takes on an aspx page
before hitting a submit button. Since there is that whole server-side
vs. client-side issue, I was thinking I can store the current time in
a variable on server side, and when the user hits submit, inside the
method invoked I take the difference of the time now and the
previously stored time.

It all makes sense right? And I'm new with ASP.NET coding, so I'd
appreciate if someone can show me a little bit of code so I know which
libraries to use and the syntax.

Thank you in advance.

Asad

Nov 18 '05 #4

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

Similar topics

4
by: Christine | last post by:
I've implemented a countdown timer for a tutorial web page that should give the user 45 minutes to complete the test, only to find that the timer is slowly 'losing' time. On average, it actually...
4
by: James Bond 007 | last post by:
I am a novice to Javascript (can do simple text-based pop-ups, but not familiar with variable manipulation). I would like to have a Javascript that gives me the start time (I don't care about...
2
by: 23s | last post by:
My site's login page has a form w/ 2 textboxes and a submit button. If I'm in either of those textboxes (i.e., either one of the textboxes has focus), in any given browser, hitting "enter" on my...
1
by: Asad | last post by:
Hi, I was wondering how I can find out the time user takes on an aspx page before hitting a submit button. Since there is that whole server-side vs. client-side issue, I was thinking I can store...
1
by: Michael E. O. Borchert | last post by:
I'm having a very isolated problem using with (I believe) windows integrated security on a site on a corporate intranet, unfortunately the one person who is running into the problem is the main...
4
by: prashanth | last post by:
we have a Asp.net application which is used to generate the reports. In this application there are some reports which takes more than 50 minutes of the time.these reports works fine on development...
2
by: Kevin Frey | last post by:
Hello, I've been reading that ASP.NET serialises (ie. processes one at a time) HTTP requests if two simultaneous requests need to access the same session state. It also makes note that ASP.NET...
1
by: William Sullivan | last post by:
I've got a website that may, on occasion, display a large list of items in a bulletedlist control. On the client side, it takes about 4 seconds to get a response that weighs in at over 1mb. It...
23
by: mosesdinakaran | last post by:
Hi All, I need a small clarification in submitting the forms, Ur suggestions please. In a page I have two form and also two submit butons. (ie)
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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.