asp:TextBox id="TextBox1" runat="server" Width="240px"></asp:TextBox>
<asp:Button id="ButtonOK" runat="server" BorderWidth="1px" BorderColor="Purple" BorderStyle="Solid" Text="Search Site"></asp:Button>
解决方法:
程序代码
<SCRIPT LANGUAGE="javascript">
function EnterKeyClick(button)
{
if (event.keyCode == 13)
{
event.keyCode=9;
event.returnValue = false;
document.all[button].click();
}
}
</SCRIPT>
在Page_Load事件中添加:
{
TextBox1.Attributes.Add("onkeydown","EnterKeyClick('ButtonOK');");
}
<asp:Button id="ButtonOK" runat="server" BorderWidth="1px" BorderColor="Purple" BorderStyle="Solid" Text="Search Site"></asp:Button>
解决方法:
![](http://blog.nwtbb.cn/images/code.gif)
<SCRIPT LANGUAGE="javascript">
function EnterKeyClick(button)
{
if (event.keyCode == 13)
{
event.keyCode=9;
event.returnValue = false;
document.all[button].click();
}
}
</SCRIPT>
在Page_Load事件中添加:
{
TextBox1.Attributes.Add("onkeydown","EnterKeyClick('ButtonOK');");
}