aspx thread: Submitting a form by pressing enter -> no submit button onclick event fired!
When I submit a form by pressing the enter key in a text box, the
form submits, but the submit button's onclick event doesn't get
fired... Is there an easy way round this?
Code sample:
><%@ Page language=3D"c#" Codebehind=3D"WebForm1.cs"
AutoEventWireup=3D"false" Inherits=3D"Test.WebForm1" %>
>
><html>
> <head>
> <meta name=3D"GENERATOR" Content=3D"Microsoft Visual Studio 7.0">
> <meta name=3D"CODE_LANGUAGE" Content=3D"C#">
> </head>
> <script language=3D"c#" runat=3Dserver >
> void btn1_onclick(Object sender, EventArgs E){
> label1.Text=3Dtextbox1.Text;
> }
> </script>
> <body>
> <form runat=3D"server">
> <asp:label id=3D"label1" text=3D"Hello" runat=3Dserver /><br>
> Press enter in this text box:<asp:textbox id=3D"textbox1"
text=3D"stuff here" runat=3DServer />
> <asp:Button id=3D"button1" text=3D"Post form" runat=3DServer
OnClick=3Dbtn1_onclick/>
> </form>
> </body>
></html>
- David Brophy
Director, Cambro Limited,
(023) 80 679550
d.brophy@c...