Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Enter in textbox causes bad postback

Reply
Thread Tools

Re: Enter in textbox causes bad postback

 
 
vMike
Guest
Posts: n/a
 
      09-22-2004

"Tony Hedge" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
> I can briefly explain without providing any code, it's a simple NET 1.1

web
> project.
>
> I have a web form with a textbox A and button A (in a table row), and
> textbox B and button B (in a second table row). The textboxes are of type
> asp:Textbox and buttons are asp:Button. Autopostback=false for textboxes.
> Click event used for the buttons.
>
> When user types in text in textbox B and hits Enter, the click event for
> button A fires!!! Why, what is causing this to happen? I would like some
> way to make button B fire instead, so I set the tabindex attributes on

each
> of the 4 controls above to try and provide that functionality but it

didn't
> work. the event for button A always fires when I ht enter.
>
> When I added textbox C and button C, etc... the same darn thing!!! How

can
> I at least turn off this behavior so that when Enter is hit no postback
> occurs? I set autopostback to false for the textboxes but this didn't do
> anything.
>
> Thanks in advance- Hedge


Try something like this.
<script language="javascript">
function testForEnter()
{
if (event.keyCode == 13)
{
event.cancelBubble = true;
event.returnValue = false;
}
}
</script>


 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9ueSBIZWRnZQ==?=
Guest
Posts: n/a
 
      09-22-2004
Hi vMike,

My fallback was to do what you suggested, thanks for the good code snippet.

I'm still thinking for a non client side solution, until I am thoroughly
beaten. (Won't take long at this rate.. )

Thanks - Hedge

"vMike" wrote:

>
> "Tony Hedge" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello,
> > I can briefly explain without providing any code, it's a simple NET 1.1

> web
> > project.
> >
> > I have a web form with a textbox A and button A (in a table row), and
> > textbox B and button B (in a second table row). The textboxes are of type
> > asp:Textbox and buttons are asp:Button. Autopostback=false for textboxes.
> > Click event used for the buttons.
> >
> > When user types in text in textbox B and hits Enter, the click event for
> > button A fires!!! Why, what is causing this to happen? I would like some
> > way to make button B fire instead, so I set the tabindex attributes on

> each
> > of the 4 controls above to try and provide that functionality but it

> didn't
> > work. the event for button A always fires when I ht enter.
> >
> > When I added textbox C and button C, etc... the same darn thing!!! How

> can
> > I at least turn off this behavior so that when Enter is hit no postback
> > occurs? I set autopostback to false for the textboxes but this didn't do
> > anything.
> >
> > Thanks in advance- Hedge

>
> Try something like this.
> <script language="javascript">
> function testForEnter()
> {
> if (event.keyCode == 13)
> {
> event.cancelBubble = true;
> event.returnValue = false;
> }
> }
> </script>
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to disable imagebutton postback when i enter "enter" =?Utf-8?B?am9l?= ASP .Net 0 09-28-2006 06:46 AM
capturing from text area Shft+Enter, Control+Enter, Alt+Enter and browser issue. HopfZ Javascript 0 08-28-2006 10:11 AM
Pressing <ENTER> in text input control causes a postback ! peshrad ASP .Net 4 08-26-2005 02:32 PM
RE: Enter in textbox causes bad postback =?Utf-8?B?RGVtZXRyaQ==?= ASP .Net 1 09-22-2004 08:11 PM
Enter in textbox causes bad postback =?Utf-8?B?VG9ueSBIZWRnZQ==?= ASP .Net 0 09-22-2004 07:19 PM



Advertisments