- <asp:TextBox id="tbInput" runat="server" Width="240px"></asp:TextBox>
- <asp:Button id="btnOK" runat="server" BorderWidth="1px" BorderColor="Purple" BorderStyle="Solid" Text="Search Site"></asp:Button>
页面添加
- <SCRIPT LANGUAGE="javascript">
- function SubmitKeyClick(button)
- {
- if (event.keyCode == 13)
- {
- event.keyCode=9;
- event.returnValue = false;
- document.all[button].click();
- }
- }
- // -->
- </SCRIPT>
后台的Page_Load()方法添加:
- tbInput.Attributes.Add("onkeydown","SubmitKeyClick('ctl00$ContentPlaceHolder1$bt_search');");