Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Textboxes & Buttons on 1 Form

Status
Not open for further replies.

byrne1

Programmer
Aug 7, 2001
415
US
In the page below I have multiple buttons along with two textboxes and two search buttons. What I want to do is give the user the ability to press Enter in either textbox and then to process information according to which textbox received the Enter key command.

Right now if the user types text in either textbox and presses enter the first button on the form is "clicked". Is there a way to do this in ASP.NET? I looked for an OnKeyPressed event in the textbox but there is not one.

Any ideas?


<%@ Page Language=&quot;vb&quot; AutoEventWireup=&quot;false&quot; Codebehind=&quot;Main.aspx.vb&quot; Inherits=&quot;Payroll_Application.WebForm1&quot;%>
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content=&quot;False&quot; name=&quot;vs_showGrid&quot;>
<meta content=&quot;Microsoft Visual Studio.NET 7.0&quot; name=&quot;GENERATOR&quot;>
<meta content=&quot;Visual Basic 7.0&quot; name=&quot;CODE_LANGUAGE&quot;>
<meta content=&quot;JavaScript&quot; name=&quot;vs_defaultClientScript&quot;>
<meta content=&quot; name=&quot;vs_targetSchema&quot;>
<!--#include file=&quot;PayAppHeader.aspx&quot; -->
</HEAD>
<body>
<form id=&quot;Form1&quot; method=&quot;post&quot; runat=&quot;server&quot;>
<table borderColor=&quot;darkblue&quot; cellSpacing=&quot;0&quot; cellPadding=&quot;5&quot; bgColor=&quot;lemonchiffon&quot; border=&quot;1&quot;>
<tr>
<td align=&quot;middle&quot; bgColor=&quot;darkblue&quot;><asp:label id=&quot;lblTasks&quot; Font-Italic=&quot;True&quot; Runat=&quot;server&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;yellow&quot;>TASKS</asp:label></td>
<td align=&quot;middle&quot; bgColor=&quot;darkblue&quot;><asp:label id=&quot;Label2&quot; Font-Italic=&quot;True&quot; Runat=&quot;server&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;yellow&quot;>REPORTS</asp:label></td>
</tr>
<tr>
<td>
<table>
<tr>
<td style=&quot;WIDTH: 17px&quot;><font size=&quot;-1&quot;><i><asp:button id=&quot;Button2&quot; runat=&quot;server&quot; Height=&quot;21px&quot; Width=&quot;88px&quot; Font-Size=&quot;XX-Small&quot; Text=&quot;New Record&quot; Font-Italic=&quot;True&quot;></asp:button></i></font></td>
<TD><asp:button id=&quot;Button5&quot; runat=&quot;server&quot; Height=&quot;21px&quot; Width=&quot;104px&quot; Font-Size=&quot;XX-Small&quot; Text=&quot;Alternate Payment&quot; Font-Italic=&quot;True&quot;></asp:button></TD>
<TD><font size=&quot;-1&quot;><i><asp:button id=&quot;Button1&quot; runat=&quot;server&quot; Height=&quot;21px&quot; Width=&quot;88px&quot; Font-Size=&quot;Smaller&quot; Text=&quot;Upload Abra&quot; Font-Italic=&quot;True&quot;></asp:button></i></font></TD>
</tr>
</table>
</td>
<td>
<table cellPadding=&quot;5&quot; border=&quot;0&quot;>
<tr>
<TD style=&quot;WIDTH: 80px&quot;><asp:button id=&quot;Button4&quot; runat=&quot;server&quot; Height=&quot;21px&quot; Font-Size=&quot;XX-Small&quot; Text=&quot;New Record Report&quot; Font-Italic=&quot;True&quot;></asp:button></TD>
<td><font size=&quot;-1&quot;><i><asp:button id=&quot;Button3&quot; runat=&quot;server&quot; Height=&quot;21px&quot; Font-Size=&quot;Smaller&quot; Text=&quot;401K Report&quot; Font-Italic=&quot;True&quot;></asp:button></i></font></td>
<TD><font size=&quot;-1&quot;><i><asp:button id=&quot;Button6&quot; runat=&quot;server&quot; Height=&quot;21px&quot; Font-Size=&quot;Smaller&quot; Text=&quot;4th Thursday Report&quot; Font-Italic=&quot;True&quot;></asp:button></i></font></TD>
</tr>
</table>
</td>
</tr>
<tr>
<td align=&quot;middle&quot; bgColor=&quot;darkblue&quot;><asp:label id=&quot;Label3&quot; Font-Italic=&quot;True&quot; Runat=&quot;server&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;yellow&quot;>QUICK LOOKUP</asp:label></td>
<td align=&quot;middle&quot; bgColor=&quot;darkblue&quot;><asp:label id=&quot;Label5&quot; Font-Italic=&quot;True&quot; Runat=&quot;server&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;yellow&quot;>SEARCH</asp:label></td>
</tr>
<tr>
<TD>ID #:<asp:textbox id=&quot;txtIDNbr&quot; Runat=&quot;server&quot;></asp:textbox><asp:button id=&quot;btnTrialBal&quot; runat=&quot;server&quot; Height=&quot;21px&quot; Font-Size=&quot;XX-Small&quot; Text=&quot;Quick Lookup&quot; Font-Italic=&quot;True&quot;></asp:button></TD>
<td>
<table cellPadding=&quot;10&quot;>
<tr>
<td>Find records where
<asp:dropdownlist id=&quot;ddlField&quot; Runat=&quot;server&quot;></asp:dropdownlist></td>
<td><asp:dropdownlist id=&quot;ddlQualifier&quot; Runat=&quot;server&quot;></asp:dropdownlist></td>
<td><asp:textbox id=&quot;txtSearchVal&quot; Runat=&quot;server&quot;></asp:textbox></td>
<td><asp:button id=&quot;Button8&quot; Font-Size=&quot;XX-Small&quot; Text=&quot;Search&quot; Runat=&quot;server&quot;></asp:button></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<br>
<asp:datagrid id=&quot;DataGrid1&quot; runat=&quot;server&quot; Font-Size=&quot;10pt&quot; AlternatingItemStyle-BackColor=&quot;#ffffcc&quot; autogeneratecolumns=&quot;False&quot; DataKeyField=&quot;IDNbr&quot; OnEditCommand=&quot;DataGrid_Edit&quot; OnCancelCommand=&quot;DataGrid_Cancel&quot; OnUpdateCommand=&quot;DataGrid_Update&quot; AllowPaging=&quot;True&quot; PageSize=&quot;15&quot;>
<AlternatingItemStyle BackColor=&quot;#FFFFCC&quot;></AlternatingItemStyle>
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField=&quot;IDNbr&quot; DataNavigateUrlFormatString=&quot;Roundhouse.aspx?IDNbr={0}&quot; DataTextField=&quot;IDNbr&quot; HeaderText=&quot;ID #&quot; NavigateUrl=&quot;Roundhouse.aspx&quot;>
<HeaderStyle Font-Bold=&quot;True&quot; HorizontalAlign=&quot;Center&quot; ForeColor=&quot;Yellow&quot; BackColor=&quot;DarkBlue&quot;></HeaderStyle>
</asp:HyperLinkColumn>
<asp:BoundColumn DataField=&quot;EmplID&quot; HeaderText=&quot;Empl ID&quot;>
<HeaderStyle Font-Bold=&quot;True&quot; HorizontalAlign=&quot;Center&quot; ForeColor=&quot;Yellow&quot; Width=&quot;100px&quot; BackColor=&quot;DarkBlue&quot;></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField=&quot;Name&quot; HeaderText=&quot;Empl Name&quot;>
<HeaderStyle Font-Bold=&quot;True&quot; HorizontalAlign=&quot;Center&quot; ForeColor=&quot;Yellow&quot; Width=&quot;100px&quot; BackColor=&quot;DarkBlue&quot;></HeaderStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderStyle-BackColor=&quot;DarkBlue&quot; HeaderStyle-ForeColor=&quot;Yellow&quot; HeaderStyle-Font-Bold=&quot;True&quot;>
<HeaderTemplate>
Debt Type
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID=&quot;lblDebtType&quot; Runat=&quot;server&quot; Text='<%# DataBinder.Eval(Container, &quot;DataItem.DebtType&quot;) %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID=&quot;lblEditDebtType&quot; Runat=&quot;server&quot;></asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderStyle-BackColor=&quot;DarkBlue&quot; HeaderStyle-ForeColor=&quot;Yellow&quot; HeaderStyle-Font-Bold=&quot;True&quot;>
<HeaderTemplate>
Payee ID
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID=&quot;Label1&quot; Runat=&quot;server&quot; Text='<%# DataBinder.Eval(Container, &quot;DataItem.PayeeID&quot;) %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID=&quot;ddlPayeeID&quot; Runat=&quot;server&quot; AutoPostBack=&quot;True&quot; OnSelectedIndexChanged=&quot;LookupPayee&quot;></asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderStyle-BackColor=&quot;DarkBlue&quot; HeaderStyle-ForeColor=&quot;Yellow&quot; HeaderStyle-Font-Bold=&quot;True&quot;>
<HeaderTemplate>
Payee
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID=&quot;lblPayee&quot; Runat=&quot;server&quot; Text='<%# DataBinder.Eval(Container, &quot;DataItem.Payee&quot;) %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID=&quot;lblEditPayee&quot; Runat=&quot;server&quot;></asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn HeaderStyle-BackColor=&quot;darkblue&quot; ButtonType=&quot;LinkButton&quot; UpdateText=&quot;Update&quot; CancelText=&quot;Cancel&quot; EditText=&quot;Edit&quot;></asp:EditCommandColumn>
<asp:ButtonColumn HeaderStyle-BackColor=&quot;darkblue&quot; Text=&quot;Delete&quot; CommandName=&quot;Delete&quot;></asp:ButtonColumn>
</Columns>
<PagerStyle HorizontalAlign=&quot;Center&quot; Mode=&quot;NumericPages&quot;></PagerStyle>
</asp:datagrid><br>
</form>
</body>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top