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

I have a asp.net/vb.net 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)
LVL 1
JReamAsked:
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,
set
style="display:none" (NOT visible = false)  on the textbox to hide the textbox from the user.
0
 
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 = DateTime.now();
    
    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;
}
</script>

Open in new window

then your buttons would be:

<asp:Button  ID="CookieButton" OnClientClick="appendText(this);" />
0
 
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 vb.net for further manipulation (ie: save to DB)
0
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.