0

I have an asp.net page containing several Text Boxes and 2 buttons; Search and Reset.

When the user presses the enter key, the search should execute without the user having to click the Search button.

I am using VS 2010 C#.

This is my code below:

<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> 

Thanks.

Craig M
  • 5,598
  • 4
  • 32
  • 43
user2217726
  • 17
  • 1
  • 8

1 Answers1

0

You can wrap your form into a Panel and use the DefaultButton-Property. As the value of the property you set the ID of the search button.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.panel.defaultbutton%28v=vs.110%29.aspx

<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>
mboldt
  • 1,780
  • 11
  • 15