SingleClick Button and 'Enter' on Search form

5 posts, 0 answers
  1. Eli
    Eli avatar
    11 posts
    Member since:
    Mar 2011

    Posted 16 Mar Link to this post

    I have a search form with many fields set up and working fine.  When I set the "Search" RadButton to SingleClick=True, it will no longer submit the form when pressing ENTER in the various input search boxes.  It appears the page does a postback but the button click event is never fired.  The button works as expected when clicking, but often users will use tab and enter text and then press enter on the form rather than clicking the button.  Suggestions?
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 17 Mar Link to this post

    Hi Eli,

    Try to set defaultbutton="YourButtonId" in the form declaration.

    https://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlform.defaultbutton%28v=vs.110%29.aspx

    Regards,
    Vasil
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Eli
    Eli avatar
    11 posts
    Member since:
    Mar 2011

    Posted 17 Mar in reply to Vasil Link to this post

    The Form tag is on a Masterpage so I did not think to do it this way, but it appears to work well.  Thank you.

     

    Dim mp As MasterPage = Me.Page.Master
    Dim form As HtmlForm = CType(mp.FindControl("Form1"), HtmlForm)
    form.DefaultButton = Me.rbSearch.UniqueID
  5. Julien
    Julien avatar
    3 posts
    Member since:
    Jun 2016

    Posted 07 Jul Link to this post

    It does not fix the problem, it only hides it.
  6. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 07 Jul Link to this post

    Hello Julien,

    Yes, if we consider that HTML specification by design to have a problem.

    Anyway the issue is not in our controls by any means. Most of the people just place hidden button on their pages and make it default button, to prevent unwanted submit by the form itself.

    You can check for example this thread:
    http://stackoverflow.com/questions/15510680/submit-on-enter-multiple-inputs
    If you have 2 inputs in the page, pressing enter will submit the form even if there is no button
    If you have 1 or 3 inputs in the page, pressing enter will do nothing.

    It is called Implicit submission:
    https://www.w3.org/TR/html5/forms.html#implicit-submission

    So in case the button is not real <button> but <input>, and you have 1 more input. When you press enter, the form will submit, but the target will not be your "button". The target will be empty. In this case the framework can not know what control caused the postback, so the handler is not executes.

    We can call it hiding or resolving the problem, but in both cases, the behavior is expected and solution is in general proven.

    Regards,
    Vasil
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017