During the development process, I was always confused by the problem: if there are several logical forms on the page, it would be okay if you click the corresponding buttons. However, if you press enter directly after entering the form content, the form will be submitted but will not be processed.
In the past, we had to write a JS script. Today we finally found a simple method.
We only need to set the defaultbutton attribute on the form parent container and set its value to the button we want the user to click. In this way, when the user presses the carriage return, it will precisely submit the desired form.
Example:
<Asp: Panel id = "pnllogin" runat = "server" cssclass = "right_login" defaultbutton = "btnlogon">
<Table>
<Tr>
<TD> <p> User name: </P> </TD>
<TD> <asp: textbox id = "tbxusername" runat = "server" cssclass = "login"> </ASP: textbox> </TD>
</Tr>
<Tr>
<TD> <p> password </P> </TD>
<TD>
<Asp: textbox id = "tbxpassword" runat = "server" cssclass = "login" textmode = "password"> </ASP: textbox>
<Asp: button id = "btnlogon" runat = "server" cssclass = "searchsubmit" text = "Logon" onclick = "btnlogon_click"/>
</TD>
</Tr>
</Table>
</ASP: Panel>
After this setting, you can press enter and click "Log on" to achieve the same effect. It is very user-friendly and convenient, isn't it?