This is a migrated thread and some comments may be shown as answers.

The server-side OnClick event is not raised when clicking on the Button text (Lightweight RenderMode, Chrome/Edge browsers, Q3 2015 SP1 release)

0 Answers 91 Views
Button
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Telerik Admin
Top achievements
Rank 1
Telerik Admin asked on 24 Nov 2015, 09:14 PM

In the Q3 2015 SP1 release the server-side OnClick event of RadButton is not raised when the following conditions are met:

  • The RenderMode of the button is set to Lightweight.
  • The .aspx page is opened under Chrome or Edge browser.
  • The button triggers an AJAX request.
  • The text of the button is clicked.

The issue will be fixed for the official Q1 2016 release and the 2015.3.1124 internal build.

For the time being you can use one of the following resolutions:

  • Set the UseSubmitBehavior property of the button to false
    <telerik:RadButton ID="RadButton1" runat="server" UseSubmitBehavior="false" Text="Click" OnClick="RadButton1_Click" RenderMode="Lightweight" />
  • OR place the following JavaScript workaround below the button's declaration (e.g., at the end of the page/master page):

    <script>
        var $T = Telerik.Web.UI;
        $T.RadButton.prototype._mouseClickHandler = function (args) {
            var button = this, result;
            var target = args.target;
            var e = args.rawEvent;
            var element = button.get_element();
      
            if (target !== element && $telerik.isDescendant(element, target)) {
                $telerik.cancelRawEvent(e);
                simulateMouseEvent(element, "click", e);
                return;
            }
      
            try {
                if (button._functionality.clicking(args) && !element.getAttribute("rwOpener")) {
                    button._functionality.click(args);
                    result = button._functionality.clicked(args);
                }
            }
            finally {
                button._mouseUp(args);
                button._restoreFlags();
                setTimeout(function () { Page_BlockSubmit = false; }, 0);
                return !result ? $telerik.cancelRawEvent(e) : true;
            }
        };
      
        function simulateMouseEvent(element, eventName, args) {
            var o = $telerik.$.extend({}, args || {});
            var oEvent;
      
            if (document.createEvent) {//deprecated DOM2 Event Model
                oEvent = document.createEvent("MouseEvents");
                oEvent.initMouseEvent(eventName, o.bubbles, o.cancelable, document.defaultView,
                                      o.button, o.screenX, o.screenY, o.clientX, o.clientY,
                                      o.ctrlKey, o.altKey, o.shiftKey, o.metaKey, o.button, element);
            }
            else if ("MouseEvent" in window) {//standard DOM3 Event Mode
                oEvent = new MouseEvent('click', o);
            }
            oEvent && element.dispatchEvent(oEvent);
      
            if (!oEvent) {//IE
                oEvent = extend(document.createEventObject(), o);
                element.fireEvent('on' + eventName, oEvent);
            }
      
            return element;
        }
      
        function extend(destination, source) {
            for (var property in source) {
                destination[property] = source[property];
            }
            return destination;
        }
    </script>

 

Tags
Button
Asked by
Telerik Admin
Top achievements
Rank 1
Share this question
or