我的代码很少<asp:ImageButton>
。但是当我按 Enter 键时我想做,而不是其他人改变但只有提交按钮有效。现在,当我在代码中按 Enter 键时,.calendar
班级按钮正常工作并且日历出现。
jquery的
$('form').keypress(function (e) {
if (e.which == 13) {
$('.submit').submit();
//return false;
}
});
的.aspx
<div id="form">
<div id="main">
<div>
<ul>
<li>
<asp:TextBox ID="txtDate1" runat="server" CssClass="textbox"></asp:TextBox>
<asp:ImageButton ID="Button1" CssClass="calbutton" runat="server" OnClick="Button1_Click" Text="Show Calendar" AutoPostBack="True"/>
<div class="calendar">
<asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged" Visible="False">
</asp:Calendar>
</div>
</li>
<li>
<asp:ImageButton ID="ImageView" CssClass="submit" runat="server" onclick="ImageView_Click" AutoPostBack="True" />
</li>
</ul>
</div>
答案 0 :(得分:0)
包装在asp:面板中并设置默认按钮。
答案 1 :(得分:0)
这样的事情对你来说可能有用..:)
<强> HTML 强>
<form id="myForm">
<div id="main">
<div>
<ul>
<li>
<asp:TextBox ID="txtDate1" runat="server" CssClass="textbox"></asp:TextBox>
<asp:ImageButton ID="Button1" CssClass="calbutton" runat="server" OnClick="Button1_Click" Text="Show Calendar" AutoPostBack="True" />
<div class="calendar">
<asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged" Visible="False"></asp:Calendar>
</div>
</li>
<li>
<asp:ImageButton ID="ImageView" CssClass="submit" runat="server" onclick="ImageView_Click" AutoPostBack="True" />
</li>
</ul>
</div>
</div>
</form>
<强>脚本强>
$('#myForm input').keypress(function (e) {
if (e.which == 13) {
$("#myForm").submit();
return false;
}
});