|
 |
aspx thread: Re: Submitting a form by pressing enter -> no submit button onclick event fired!
Message #1 by "Julie Gephart" <gephart@w...> on Fri, 7 Feb 2003 02:13:06
|
|
I am having the same problem on some forms but not on others, and I'm
going crazy trying to find the solution. In fact, I have one form that
contains a text box and some checkboxes, and pressing Enter while in the
textbox skips the onclick event, but pressing enter while on a checkbox
fires the event. I can't seem to narrow down what might be going on, so
any help would be appreciated.
-Julie Gephart
gephart@w...
> 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...
Message #2 by "Rajkumar" <rajms@h...> on Mon, 10 Feb 2003 17:21:01 +0530
|
|
Try
------------------------------------------------------ code
---------------------------------
Page.RegisterHiddenField("__EVENTTARGET", "submit-buton-id")
------------------------------------------------------ code
---------------------------------
in page_load subroutine.
Hope it will help.
Rajkumar
-------Original Message-------
From: ASP.NET
Date: Friday, February 07, 2003 07:30:09 AM
To: ASP.NET
Subject: [aspx] Re: Submitting a form by pressing enter -> no submit button
onclick event fired!
I am having the same problem on some forms but not on others, and I'm
going crazy trying to find the solution. In fact, I have one form that
contains a text box and some checkboxes, and pressing Enter while in the
textbox skips the onclick event, but pressing enter while on a checkbox
fires the event. I can't seem to narrow down what might be going on, so
any help would be appreciated.
-Julie Gephart
gephart@w...
> 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...
.
|
|
 |