Using VB.Net - how to record the time of each client side button click

I have a web app and I need to capture the click time of each button click without doing a post-back on each click. Once I capture these times, I would then like to store in DB.

The webform has 5 dynamically created buttons. Each button is used like a ranking mechanism. So on the form - a question would be asked like: Which one do you like the most? 1) Cookies, 2) Cake, 3) Ice Cream, 4) Hamburger or 5) Hot Dog..

I need for the user to rank each option but record click time of each (not for display but for storing in DB)
Who is Participating?
Kyle AbrahamsSenior .Net DeveloperCommented:
Create another textbox, visible for now.

Append the text to this new textbox (rather than the alert)

when you finally post back, the server will have access to the text in the textbox, which can then be saved.

when you're finally all done,
style="display:none" (NOT visible = false)  on the textbox to hide the textbox from the user.
Kyle AbrahamsSenior .Net DeveloperCommented:
you would have to do it in javascript.

Create a hidden text field:

then use the javascript to append the text:

<script type="text/javascript">

    //Get the current date and time stamp.
   function appendText (sender)
    var date =;
    var TheTextBox = document.getElementById("Mytextbox");  // you can also use <%MyTextbox.ClientID %> if you're in a content page
    TheTextBox.value = TheTextBox.value + sender.ID + " " + date;

Open in new window

then your buttons would be:

<asp:Button  ID="CookieButton" OnClientClick="appendText(this);" />
JReamAuthor Commented:
I was able to obtain the button click times with each click displayed within an alert message box (as a test) but my main issue is storing those java-script button click times to a variable that I can use in for further manipulation (ie: save to DB)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.