在文本框中输入文本后如何设置默认按钮。这就是我到目前为止所拥有的。但它不起作用
<td>
<asp:Label ID="displayrowLabel" runat="server" Text="# of Rows Displayed:"></asp:Label>
<asp:TextBox ID="displayRowQuery" runat="server"></asp:TextBox>
<asp:Button ID="displayRowButton" runat="server" Text="Click" OnClick="ddlPageItems_SelectedIndexChanged" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="displayRowQuery" ValidationExpression="[1-9][0-9]*" ErrorMessage="Wrong Input" />
</td>
</tr>
</table>
</PagerTemplate>
我尝试添加一些 jquery 来处理这个问题:
<script type="text/javascript">
$("displayRowQuery").keyup(function (event) {
if (event.keyCode == 13) {
$("displayRowButton").click();
}
});