Wrong Button.OnClick() for TextBox

  • Thread starter Thread starter Lenard Gunda
  • Start date Start date
L

Lenard Gunda

Hi!

I have an ASP.NET page with multiple TextBox fields and buttons. When I
press the <enter> key in a TextBox, the page postbacks, and one of the
buttons get fired (OnClick). Now certain TextBoxes trigger one particular
button on the page (this is the first button on the page, so probably that's
why that gets fired), while there is one TextBox, that seems to trigget
another one. I have no idea what's the difference between the TextBoxes, why
some fire this button and the others another..

Is there a way to specify which TextBox triggers which Button on the <enter>
keypress? I didn't find anything, like a default button for the form, or
something like that. But I would like to specify a default button on a per
control (that is, per TextBox) basis.

Thanks

Lenard Gunda
 
Lenard Gunda a écrit :
Hi!

I have an ASP.NET page with multiple TextBox fields and buttons. When I
press the <enter> key in a TextBox, the page postbacks, and one of the
buttons get fired (OnClick). Now certain TextBoxes trigger one particular
button on the page (this is the first button on the page, so probably that's
why that gets fired), while there is one TextBox, that seems to trigget
another one. I have no idea what's the difference between the TextBoxes, why
some fire this button and the others another..

Is there a way to specify which TextBox triggers which Button on the <enter>
keypress? I didn't find anything, like a default button for the form, or
something like that. But I would like to specify a default button on a per
control (that is, per TextBox) basis.

Thanks

Lenard Gunda

You can use a specific control witch allows to specify the button on
thr action.
Go to http://www.metabuilders.com and use the DefaultButtons

Hope this help you
 
use this Page.RegisterHiddenField("__EVENTTARGET",btnSearch.ClientID);

but it will fire for every text box that your cursor is in and you press
enter.

Av.
 
Back
Top