Completed
Last Updated: 15 Jan 2016 17:08 by ADMIN
ADMIN
Danail Vasilev
Created on: 24 Nov 2015 16:05
Category: Button
Type: Bug Report
0
The server-side OnClick event is not raised when clicking on the Button text with Lightweight rendering in Chrome/Edge
For the time being you can either set the UseSubmitBehavior property of the button to false or place the following JavaScript workaround below the button's declaration:
ASPX:
	<form id="form1" runat="server">
		<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
		<asp:UpdatePanel ID="Updatepanel1" runat="server">
			<ContentTemplate>
				<telerik:RadButton ID="RadButton1" runat="server" Text="Click" OnClick="RadButton1_Click" RenderMode="Lightweight" />
				<asp:Label ID="Label1" Text="" runat="server" />
			</ContentTemplate>
		</asp:UpdatePanel>
		<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>
	</form>
C#:
	protected void RadButton1_Click(object sender, EventArgs e)
	{
		Label1.Text = DateTime.Now.ToString();
	}
0 comments