我在form标签中调用onclick,onmousemove和onkeypress事件上的函数,函数在代码后面,但是当用户单击,按下一个键并在form1上移动鼠标时,该方法不会执行。代码是:
<form id="form1" runat="server" onclick="idletime()" onkeypress="idletime()" onmousemove="idletime()">
.cs文件:
protected void idletime(object sender, EventArgs e)
{
Response.Write("hello.");
}
答案 0 :(得分:0)
你可以使用ajax来做到这一点。我正在写一些粗略的示例代码。希望它可能有所帮助。
KeyFactory
c#code
<form id="form1" runat="server" onclick="idletime()" onkeypress="idletime()" onmousemove="idletime()">
<script>
function idletime() {
$.ajax({
type: "POST",
url: "demo.aspx/functionName1",
data: "{parameter1:'" + param1 "',parameter2:'" + param2 + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg.d);
}
});
}
</script>