Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6334071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:35:19+00:00 2026-05-24T18:35:19+00:00

I am in the process of handling a Long Press event in the JavaScript

  • 0

I am in the process of handling a Long Press event in the JavaScript of an ASPX page but since I don’t have much experience with JavaScript having a couple issues. I am working of a question which was already asked here.

When I run the code I get the message “$ is not defined” and when I change $(“Button1”) to (“Button1”) then I get the message stating the mouseup function doesn’t exist. The primary problem I’m having is accessing the aspx control properly. Below is my code.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" language="javascript">
        $(function () {
            var pressTimer;
            var longPress = 1000;

            $("#<%= Label1.ClientID %>").bind("touchend", function (e) {
                var d = new Date();
                var timeDiff = d - pressTimer
                if (timeDiff > longPress) {
                    document.getElementById("demo").innerHTML = "Mouse Up";
                    //actual logic here
                }
                return false;
            });
            $("#<%= Label1.ClientID %>").bind("touchstart", function (e) {
                pressTimer = new Date();
                return false;
            });
        });
    </script>
    <title>Long Press Testing</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:label ID="Label1" runat="server" text="Hold This Down" />
        <br />
        <p id="demo"></p>
    </div>
    </form>
</body>
</html>

Thanks for the help.

[EDIT] – Turns out I was missing the ready statement so the event is now firing as it should. This is the final version which is behaving properly. Also I wrote this to handle long press functionality on the iPad so if anyone is trying to do that this code is a good place to start.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:35:20+00:00Added an answer on May 24, 2026 at 6:35 pm

    You are missing jQuery script registration in head section like:

    <script src="jquery.js"></script>
    

    $ sign is jQuery’s identifier, not JavaScript’s.

    Also, your buttons will not work, because you are referencing server button, but you must provide an id for JavaScript to work properly:

    $("#<%= Button1.ClientID %>").mouseup(function () {
            clearTimeout(pressTimer)
            // Clear timeout
            return false;
        })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code where I am handling an event twice. However I
I need to process long running requests inside IIS, handling the request itself is
I have situation when I need to communicate with Java process somehow. Java handling
My backgroundWorker uses ReportProgress to update the ProgressPercentage of a long process. What happens
I'm in the process of rewriting the error handling of PEAR's Text_LanguageDetect to exceptions
I have an Android Service running in a separate process from its client, and
I have a question about handling exception. I have a Winform that uses a
I have a process in a website (Asp.net 3.5 using Linq-to-Sql for data access)
Ok, long story short I have a Windows service that handles Win32_VolumeChangeEvent and logs
I have a situation where I'm starting a process in my code in order

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.