The damn Enter button and ASP.NET

L

Lars Netzel

If you have a Datagrid with the functionality to edit and update rows and
then also a Save, Add new and Back buttons at the bottom of the page. The
Enter button is all messed up... add to this a bunch of TextBox fileds with
Multiline support in the Edit mode...

So if I enter the Edit mode of a row and put focus in the multiline textbox
and press enter I of course want to create a line feed in the text box.. but
no.. it triggers any button the page feel like at that time... when you tab
around in the Input fields you see the blu little line jump around on
buttons (that indicated the Defautl Enter button)... Sometimes it's the save
button that triggers and sometimes in the back button or sometimes even the
deletecommand of the other rows that are not in the EditMode.

So, yeah sure I could, which I have on other pages, disabled the Enter and
Return buttons thru Javascript onkeypress but on this page I really need to
have the line feed thingy working in the Multiline boxes.. please help.

best regards
/Lars Netzel
 
G

Grant Merwitz

Hi Lars

I've had the problem with ASP pages submitting the first button on the page
or not the button i intented it to submit.
The way i got around this, was by creating a <input type=button runat=server
id=tb />, setting the OnClick to point to my required method through the
code behind, then attaching a JavaScript on enter to all the textboxes i
want to submit this with. (the opposite to you disabling the enter button)
An annoying work around, but a work around.

I have never had the problem when hitting enter on a multiline textbox, it
submits the form.
However, attaching a Javascript onclick like i said above would do this.

So, are you sure there no javascript actions on you textbox that could cause
it to submit on enter rather than create a new line feed.
Double check this through IE by viewing source and checking there is no
OnClick event.

HTH (I know it may be no solution, by no one else has answered your plea for
help yet :))
 
L

Lars Netzel

Thank you! I had some thoughts about the way you suggested but it seemed
like such an ugly workaround that I didn't really think that anyone would do
it but after looking around so more it seems like this is a quite common way
of fixing things, using the onfocus and onblur events to alter behaviors on
page.

So I did this:

I catch onkeypress on the body element and have a condition for the Enter
button to return true or false... then on the onfocus and onblur events of
the textboxes, I change a variable weather to use the condition for the
enter check or not. Work pretty darn good:)

Thanks for the thoughts.

And by the way.. the textboxes where not set to MultiLine... hmmm.. I wonder
why there was no LineFeed....

Take care

/Lars
 
G

Grant Merwitz

HAHA, thats is quite funny

glad you came right

Lars Netzel said:
Thank you! I had some thoughts about the way you suggested but it seemed
like such an ugly workaround that I didn't really think that anyone would
do it but after looking around so more it seems like this is a quite
common way of fixing things, using the onfocus and onblur events to alter
behaviors on page.

So I did this:

I catch onkeypress on the body element and have a condition for the Enter
button to return true or false... then on the onfocus and onblur events of
the textboxes, I change a variable weather to use the condition for the
enter check or not. Work pretty darn good:)

Thanks for the thoughts.

And by the way.. the textboxes where not set to MultiLine... hmmm.. I
wonder why there was no LineFeed....

Take care

/Lars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top