When you add a textbox in asp.net you need to click the submit button in order to submit the data.
Where as in regular html page you can just hit the enter key and it will submit. Is there a way around this?
Maybe in the whidbey release have the ability to group controls
You'll need some kind of submit button client-side.
This is handled by the browser, so Whidbey isn't really an issue as such.
However, in ASP.NET, all "System.Web.UI.WebControls.Button" objects are really submit-buttons. Just add one. If you don't want it to be visible, 'style="visibility: hidden"' is a possible, albeit kludgy solution.
Note that multi-line TextBoxes accepts the enter presses as lineshifts. On all webpages.
Drop the .dll into your /bin folder, add the control to your toolbox and then drag it onto your page. Click the textbox in question and you will see a property for the textbox named "Default button on <name of DefaultButtonControlID>". Just place the ID of
the default button there and voila. Works awesome.
PS: Let me know if you need help with this...
This is definately a bug. I hope the ASP.NET team reads this.
"Add this line somewhere on the page: <input type="text" style="display:none">, and all will work as expected."
Using the textbox_TextChanged event works for me.
This is actually expected behaviour in some cases. If the form has a single input text field then by w3c html 2.0 spec it should submit on enter.
"When there is only one single-line text input field in a form, the user agent should accept Enter in that field as a request to submit the form. "
If you have a textarea in your form than it wont work. This behaviour also changes depending on the browser. For instance netscape allows for textareas.
I ran a quick test that was a form with two text-Box controls and one button. I was able to submit with enter in all cases.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.