$(function () {
$("td input:text:first").focus();
var $inp = $("td input:text");
$inp.bind("keydown", function (e) {
var key = e.which;
if (key == 13) {
// alert($(this).attr("tabindex"));
if($(this).attr("tabindex")==15)
{
e.preventDefault();
$("#btnNextInputPage").click();
setTimeout("$('td input:text:first')[0].focus();",100);
}
else
{
window.event.keyCode=9;
}
}
});
});
$("td input:text:first").focus();
var $inp = $("td input:text");
$inp.bind("keydown", function (e) {
var key = e.which;
if (key == 13) {
// alert($(this).attr("tabindex"));
if($(this).attr("tabindex")==15)
{
e.preventDefault();
$("#btnNextInputPage").click();
setTimeout("$('td input:text:first')[0].focus();",100);
}
else
{
window.event.keyCode=9;
}
}
});
});
<head runat="server">
<title><%=Resources.global.IMP109001 %></title>
<script src="../JS/jquery-1.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("td input:text:first").focus();
var $inp = $("td input:text");
$inp.bind("keydown", function (e) {
var key = e.which;
if (key == 13) {
// alert($(this).attr("tabindex"));
if($(this).attr("tabindex")==15)
{
e.preventDefault();
$("#btnNextInputPage").click();
// setTimeout("$('td input:text:first')[0].focus();",100);
}
else
{
window.event.keyCode=9;
}
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server" >
<div >
<asp:ScriptManager ID="SM" runat="server">
</asp:ScriptManager>
<div style="margin:0px;left:0px;padding:0px;" >
<asp:UpdatePanel ID="upInput" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table style="width:730px;margin:auto;margin-top:0px;" >
<tr>
<td >
<asp:Label runat="server" ID="lblItemID01Name"></asp:Label>
</td>
<td >
<asp:TextBox runat="server" TabIndex="1" Width="200px" ID="txtItemID01Input"></asp:TextBox>
</td>
<td >
<asp:Label runat="server" ID="lblItemID05Name"></asp:Label>
</td>
<td >
<asp:TextBox runat="server" TabIndex="5" Width="200px" ID="txtItemID05Input"></asp:TextBox>
</td>
<td >
<asp:Label runat="server" ID="lblItemID09Name"></asp:Label>
</td>
</tr>
<tr>
<td >
<asp:Label runat="server" ID="lblItemID02Name"></asp:Label>
</td>
<td >
<asp:TextBox runat="server" TabIndex="2" Width="200px" ID="txtItemID02Input"></asp:TextBox>
</td>
<td >
<asp:Label runat="server" ID="lblItemID06Name"></asp:Label>
</td>
<td>
<asp:TextBox runat="server" TabIndex="6" Width="200px" ID="txtItemID06Input"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label runat="server" ID="lblItemID03Name"></asp:Label>
</td>
<td >
<asp:TextBox runat="server" TabIndex="3" Width="200px" ID="txtItemID03Input"></asp:TextBox>
</td>
<td >
<asp:Label runat="server" ID="lblItemID07Name"></asp:Label>
</td>
<td >
<asp:TextBox runat="server" TabIndex="7" Width="200px" ID="txtItemID07Input"></asp:TextBox>
</td>
</tr>
<tr>
<td >
<asp:Label runat="server" ID="lblItemID04Name"></asp:Label>
</td>
<td >
<asp:TextBox runat="server" TabIndex="4" Width="200px" ID="txtItemID04Input"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblInfoShow" runat="server"></asp:Label>
</td>
<td colspan="6" style="text-align:right;">
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnNextInputPage" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="btnCheck" runat="server" />
<asp:Button ID="btnNeedInputPicture" runat="server" />
<asp:Button ID="btnNextInputPage" runat="server"
onclick="btnNextInputPage_Click" TabIndex="16" />
</div>
</form>
</body>
</html>
protected void btnNextInputPage_Click(object sender, EventArgs e)
{
//改变label值
this.txtItemID01Input.Focus(); this.btnNextInputPage.Text = "下一页"; //设置button的值为“上一页”
}
else if (this.btnNextInputPage.Text == "上一页") //如果button的值为“上一页”,则执行
{
//改变label值
this.txtItemID01Input.Focus();
this.btnNextInputPage.Text = Resources.global.IMP109046; //设置button的值为“下一页”
} }
局部刷新后,我除去了其它按钮,只留下下一页按钮,发现,焦点一直停在下一页按钮上,然后按enter,就不停的局部刷新,执行下一页,上一页事件