I'm not sure if this is related just to jQuery, or if there is an issue with the Telerik version thereof.
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> |
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> |
My goal is to capture the Enter key in a textbox, and depending on the textbox which has focus, move to the next appropriate control. When I move from one textbox to another, it's fine. When I want to move from a textbox to a checkbox, I can't get an object for the checkbox, the return value (ctrl) is null. The following is in a RadCodeBlock.
function KeyPressed(ctrl, e) { |
if (e.get_domEvent().rawEvent.keyCode == 13) { |
var ID = ctrl.get_id(); |
var ctrl; |
if (ID.indexOf("F1") >= 0) ctrl = $find("<%= F2.ClientID %>"); |
if (ID.indexOf("F2") >= 0) ctrl = $("#<%= C1.ClientID %>"); // fail |
// $find("<%= C1.ClientID %>"); // this didn't work either |
if (ctrl !== null) { |
e.set_cancel(true); |
setTimeout(function() { ctrl.focus(); }, 1); |
} |
... |
} |
} |
The F1 and F2 controls are textboxes. C1 is a checkbox (all control names simplified for this text). The controls look like this:
<telerik:RadNumericTextBox ID="F1" Width="80px" runat="server" |
Type="Number" NumberFormat-DecimalDigits="0" ClientEvents-OnKeyPress="KeyPressed" /> |
... |
<telerik:RadNumericTextBox ID="F2" Width="80px" runat="server" |
Type="Number" NumberFormat-DecimalDigits="0" ClientEvents-OnKeyPress="KeyPressed" /> |
... |
<asp:CheckBox ID="C1" runat="server" Text="Check Me!" /> |
I'd like to understand what's wrong, but since we're here, outside of this kind of manual wiring, is there any more elegant way to set the Enter key to follow TabStops?
Thanks!