The simplest solution: defaultbutton = On the page needs to be set as the default button object name
<Form ID = "form1" runat = "server" defaultbutton = "OK">
Set the form attribute defaultbutton = "default button ID"
I // Write directly in JS
< Script Language = " Javascript " >
Function entertextbox ()
{
If ( Event . Keycode = 13 && Document. All [ " Textbox1 " ]. Value ! = "" )
{
Event . Keycode = 9 ;
Event . Returnvalue = False ;
Document. All [ " Textbox1 " ]. Click ();
}
}
</ Script >
< Body onkeypress = " Return entertextbox () " >
// Textbox1 is the textbox ID on the page.
II.
< Script Language = " Javascript " >
Function entertextbox (button)
{
If ( Event . Keycode = 13 && Document. All [ " Textbox1 " ]. Value ! = "" )
{
Event . Keycode = 9 ;
Event . Returnvalue = False ;
Document. All [button]. Click ();
}
}
</ Script >
In the pageload event
Textbox1.attribute. Add ( " Onkeypress " , " Entertextbox ('button1 ') " );