我有一个包含多个文本框和2个按钮的asp.net页面;搜索和重置。
当用户按下enter
键时,搜索应该在用户不必单击“搜索”按钮的情况下执行。
我正在使用VS 2010 C#。
这是我的代码:
<fieldset >
<legend class="ui-widget-header ui-corner-all">Case Search Criteria</legend>
<br />
<div>
<wuc:CustomLabel ID="lblCaseNumber" runat="Server" AssociatedControlID="txtSearchByCaseNumber" Text="Starting/Exact Case Number:" />
<asp:TextBox ID="txtSearchByCaseNumber" runat="server" />
<acTkt:FilteredTextBoxExtender ID="ftbCaseNumber" runat="server" FilterType="Custom" FilterMode="ValidChars" ValidChars="1234567890" TargetControlID="txtSearchByCaseNumber" />
</div>
<div>
<wuc:CustomLabel ID="lblCaseNumber2" runat="Server" AssociatedControlID="txtSearchByEndingCaseNumber" Text="Ending Case Number :" />
<asp:TextBox ID="txtSearchByEndingCaseNumber" runat="server" />
<acTkt:FilteredTextBoxExtender ID="ftbEndingCaseNumber" runat="server" FilterType="Custom" FilterMode="ValidChars" ValidChars="1234567890" TargetControlID="txtSearchByEndingCaseNumber" />
</div>
<div>
<wuc:CustomLabel ID="lblSSN" runat="Server" AssociatedControlID="txtSearchBySSN" Text="Employee SSN:" />
<asp:TextBox ID="txtSearchBySSN" runat="server" />
<wuc:DynamicValidators ID="dvalSSN" runat ="server" EntityName="SSN"
ControlAssociatedID="txtSearchBySSN"
MaskType="SSN" IsApplyMask="true" IsRequired="false" />
</div>
<div>
<wuc:CustomLabel ID="lblSearchByFirstName" runat="Server" AssociatedControlID="txtSearchByFirstName" Text="Employee First Name:" />
<asp:TextBox ID="txtSearchByFirstName" runat="server" MaxLength="100" />
</div>
<div class="hbuttons-ui">
<wuc:custombutton id="btnSearch" runat="Server" text="Search" disableonsubmit="true" data-button="true" />
<span class="navigation-overcast">
<wuc:custombutton id="btnReset" runat="Server" text="Reset" causesvalidation="false" data-button="true" />
</span>
</div>
感谢。
答案 0 :(得分:0)
您可以将表单包装到Panel中并使用DefaultButton-Property。作为属性的值,您可以设置搜索按钮的ID。
<asp:Panel id="Wrapper" runat="server" DefaultButton="Send">
<asp:TextBox id="SearchKeyword" runat="server"></asp:TextBox>
<asp:ButtonID="Send" runat="server">Search</asp:Button>
</asp:Panel>