Problem with DefaultButton in Q2 2012

16 posts, 1 answers
  1. Hunter
    Hunter avatar
    44 posts
    Member since:
    Aug 2012

    Posted 13 Jun 2012 Link to this post

    Did this issue come back to life in Q2? After upgrading to Q2 the issue described here was noticed in my login page which contains two radTextboxes and a radButton placed within an asp panel (default button set to radButton). If you enter a user name then use tab to enter the password, hitting enter on your keyboard (while radTextbox has focus) does nothing. Only after hitting the enter button twice or using the mouse to click back to the first textbox makes the enter key work. I tried setting the EnableSingleInputRendering to false but this did nothing. If I replace the radTextbox with an asp textbox everything works as expected.
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 14 Jun 2012 Link to this post

    Hello Hunter,

    I tested the sample code from the other thread and it is working correct with the Q2 2012.
    Do you have any specific code in your page? Do you have asp:validators to validate your inputs?

    Greetings,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hunter
    Hunter avatar
    44 posts
    Member since:
    Aug 2012

    Posted 14 Jun 2012 Link to this post

    Interesting, yes I have an asp required field validator for each textbox.
  5. Shukhrat Nekbaev
    Shukhrat Nekbaev avatar
    73 posts
    Member since:
    Oct 2010

    Posted 15 Jun 2012 Link to this post

    Hi,

    I have similar issue with Q2 2012 (was ok previously), I have a page with 2 RadTextBoxes. First is email + 2 validators (required field and regular expression), second is password (required field). Both have ClientEvents-OnKeyPress bound. In this js function I check if key is an enter key (args.get_keyCode() == 13) and click on a button. This has been working for months already. Now it's not :) If I input text to both textboxes and press enter while second is focused I get validator error: password is required, similarly if first is focused - validator saying that email is required appears. Pressing enter key second time does the login. (controls are inside LoginControl with LayoutTemplate and everything is inside updatepanel).

    My current workaround is adding a timeout:
    function loginKeyDown(event, args) {
        if (args.get_keyCode() == 13) {
            setTimeout(function() {
                $('#<%= (PGC.WebApp.BL.Utils.HelperMethods.FindControlRecursive(loginCtrl, "LoginButton") as Button).ClientID %>').click();  
            }, 50);
        }
    }

  6. Answer
    Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 15 Jun 2012 Link to this post

    Hi Shukhrat,

    I can confirm that there is issue with RadInputControl in combination with Validator and Default button. The current solution is to override the _onTextBoxKeyDownHandler as follows:

    <script type="text/javascript">
        Telerik.Web.UI.RadInputControl.prototype._onTextBoxKeyDownHandler = function (e)
        {
            if ((e.keyCode == 13 || e.keyCode == 9) && !this.isMultiLine())
            {
                this._updateHiddenValue();
            }
     
            if (e.keyCode == 27 && !$telerik.isIE)
            {
                var that = this;
                window.setTimeout(function ()
                { that.set_textBoxValue(that.get_editValue()); }, 0);
            }
        }
    </script>

    Place the script under the declaration of your ScriptManager.

    Kind regards,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  7. Shukhrat Nekbaev
    Shukhrat Nekbaev avatar
    73 posts
    Member since:
    Oct 2010

    Posted 15 Jun 2012 Link to this post

    Hi,

    thanks for the reply, I've replaced my workaround with yours :)

    P.S.: checked in IE9 (IE8 mode), IE9, Safari, FF, Chrome, seems to be ok
  8. Hunter
    Hunter avatar
    44 posts
    Member since:
    Aug 2012

    Posted 16 Jun 2012 Link to this post

    Thanks guys, works for me too! Now for the million dollar question.... When do you think we might see a fix for this? Should I add something to pits? Thanks again.
  9. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 18 Jun 2012 Link to this post

    Hello Hunter,

    This will be fixed in the next published internal build next week. You could see the status in PITS here:
    http://www.telerik.com/support/pits.aspx#/public/aspnet-ajax/11505

    All the best,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  10. Hunter
    Hunter avatar
    44 posts
    Member since:
    Aug 2012

    Posted 18 Jun 2012 Link to this post

    Thanks!
  11. Chris Dalessandri
    Chris Dalessandri avatar
    44 posts
    Member since:
    Aug 2005

    Posted 23 Jun 2012 Link to this post

    This solution does not seem to be working for me.  My situation is similar (radtextboxes with validators) but I want to click a button myself and stop the event from propagating.  The code I've used for this is:
    function keyPressHandler(sender, args) {
        if (args.get_keyCode() == 13) {
            args.set_cancel(true);
            document.getElementById('<%= btnSave.ClientID %>').click();
        }
    }

    This code has been working for a long time.  After the latest update it does not.  If I remove the set_cancel, it works in the simple case.  But on some pages I have multiple textboxes and multiple buttons and I really need to ensure that no event bubbles. I tried using get_domEvent() and canceling the event myself but that did not work.

    Help, please.

    Thank you,
  12. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 27 Jun 2012 Link to this post

    Hello Chris,

    Use sender.blur(); Or sender.set_value(sender.get_textBoxValue() ) ; when you cancel the event if you still like the text to be considered as changed.

    All the best,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  13. Chris Dalessandri
    Chris Dalessandri avatar
    44 posts
    Member since:
    Aug 2005

    Posted 28 Jun 2012 Link to this post

    Just in case anyone has a similar problem, Telerik has confirmed that there is a problem with RadInput when canceling the keypress event and they are looking into it.
  14. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 03 Jul 2012 Link to this post

    Hello,

    The issue when with the canceling the event will be fixed in 10th June hotfix. So in Service Pack of Q2 it will work correct.

    Regards,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  15. Marc Messer
    Marc Messer avatar
    17 posts
    Member since:
    May 2009

    Posted 14 Sep 2012 Link to this post

    Anyone else still having an issue with this?  I just tested and all the browsers seem to be ok except for IE 8.  I have even updated my dev environment to the latest september release with no success.  I've sent a support ticket: 605410 but they want me to send a stripped down version of a CMS / E-Commerce platform over to them.  
  16. Marc Messer
    Marc Messer avatar
    17 posts
    Member since:
    May 2009

    Posted 14 Sep 2012 Link to this post

    I actually figured out what was causing the issue... another piece of code that is needed for default buttons on the site.  Now just need to fix this code to be compatible with Q2 SP1...

    $("span[DefaultButton]").each(function () {
        var s = $(this).attr("DefaultButton");
        $("input[type='text'], input[type='password']", this).keydown(function (e) {
            var k = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
            if (k == 13) {
                e.preventDefault();
                var b = $("#" + s).eq(0);
                if (b.length > 0) {
                    if (typeof (b.get(0).onclick) == 'function') { b.trigger('click'); }
                    else if (b.attr('href')) { window.location = b.attr('href'); }
                    else { b.trigger('click'); }
                }
            }
        });
    });
  17. Martin
    Admin
    Martin avatar
    811 posts

    Posted 17 Sep 2012 Link to this post

    Hello Marc Messer,

    I have addressed the support ticket you have opened on the same topic. To make my post available for our community I am pasting it here as well:

    Just to clarify that we do not need s stripped version of your CMS application. All we need is just a sample page that replicates the issue.

    Indeed as my colleague Vasil confirmed, we had released this issue in a previous version of the controls. After it was reported and before it was fixed, our devs came with a
    temporary solution. This was an override of one of the internal RadInputControl functions. However this temporary solution is not needed for versions after Q2 2012 SP1 (2012.2.724) because a stable fix was included in the source code.

    Based on the above, the default button should work as expected in IE8
    without any additional code for versions after the one specified above. In this case any custom code added to page that affects this functionality is sole developer's responsibility and is not supported.


    I hope this helps.

    Regards,
    Martin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017