Here's how to change an asp.net label value on mouse hold. Add/reference jQuery in your asp.net app.
javascript Code:
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
var intervalHandler;
$(document).ready(function() {
$('#ButtonUp').mousedown(function() {
intervalHandler = setInterval(function() { FactUp(); }, 100);
return false;
});
$('#ButtonUp').mouseup(function () {
clearInterval(intervalHandler);
});
$('#ButtonDown').mousedown(function() {
intervalHandler = setInterval(function() { FactDown(); }, 100);
return false;
});
$('#ButtonDown').mouseup(function () {
clearInterval(intervalHandler);
});
});
function FactUp() {
var obj = $("#<%= Label1.ClientID %>").text();
var num = parseFloat(obj);
if (isNaN(num)) {
return;
}
num = parseFloat(num + 1);
$("#<%= Label1.ClientID %>").text(num);
}
function FactDown() {
var obj = $("#<%= Label1.ClientID %>").text();
var num = parseFloat(obj);
if (isNaN(num)) {
return;
}
num = parseFloat(num - 1);
$("#<%= Label1.ClientID %>").text(num);
}
</script>
aspx.
html Code:
<form id="form1" runat="server">
<div>
<input type="button" id="ButtonUp" value="+" />
<input type="button" id="ButtonDown" value="-" />
<br/>
<asp:Label ID="Label1" runat="server" Text="0" />
</div>
</form>
Code Sample: ASP.NET VS 2012
Reference: Easily do a continuous action on mouse hold using javascript