Coffeehouse Thread

7 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Annoying things about ASP.NET controls

Back to Forum: Coffeehouse
  • User profile image
    kuya

    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

  • User profile image
    Slartibartf​ast

    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.  Wink

  • User profile image
    Matt.Berther

    I had a similar issue with this and posted a solution at: http://www.mattberther.com/2003/06/000125.html

  • User profile image
    junior882

    Check out the below control. Does the trick...

    http://www.metabuilders.com/Tools/DefaultButtons.aspx

    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...

  • User profile image
    kuya

    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."

  • User profile image
    Richard Acton

    Using the textbox_TextChanged event works for me.

  • User profile image
    KevinClement

    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.

    see http://www.w3.org/MarkUp/html-spec/html-spec_toc.html

    specifically:
      "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.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.