OnClientKeyPressing not working on Firefox 2 or 3

2 posts, 1 answers
  1. Russell
    Russell avatar
    5 posts
    Member since:
    Jul 2008

    Posted 19 Nov 2008 Link to this post

    We have created a page that has a RadTreeView and have subscribed the OnClientKeyPressing event to a function. On IE 6 and 7 the event fires showing an alert but on Firefox it does nothing.

    I have attached the aspx page contents below.

    Regards
    Russell

    <%

    @ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="TreeTest.WebForm2" %>

     

    <%

    @ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

     

    <!

     

    DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

     

    <

     

    html xmlns="http://www.w3.org/1999/xhtml">

     

    <

     

    head runat="server">

     

     

    <title></title>

     

    </

     

    head>

     

    <

     

    body>

     

     

    <form id="form1" runat="server">

     

     

    <asp:ScriptManager ID="ScriptManager1" runat="server">

     

     

    </asp:ScriptManager>

     

     

     

    <script type="text/javascript">

     

     

    function test() {

     

    alert(

    'hello');

     

    }

     

     

    </script>

     

     

     

    <div>

     

     

    <telerik:RadTreeView ID="RadTreeView1" runat="server" EnableDragAndDrop="True" Skin="Outlook"

     

     

    MultipleSelect="True" OnClientKeyPressing="test">

     

     

    <Nodes>

     

     

    <telerik:RadTreeNode runat="server" Text="Root RadTreeNode1">

     

     

    <Nodes>

     

     

    <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 1">

     

     

    </telerik:RadTreeNode>

     

     

    <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 2">

     

     

    </telerik:RadTreeNode>

     

     

    <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 3">

     

     

    </telerik:RadTreeNode>

     

     

    </Nodes>

     

     

    </telerik:RadTreeNode>

     

     

    <telerik:RadTreeNode runat="server" Text="Root RadTreeNode2">

     

     

    <Nodes>

     

     

    <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 1">

     

     

    <Nodes>

     

     

    <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 1">

     

     

    <Nodes>

     

     

    <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 1">

     

     

    </telerik:RadTreeNode>

     

     

    <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 2">

     

     

    </telerik:RadTreeNode>

     

     

    </Nodes>

     

     

    </telerik:RadTreeNode>

     

     

    </Nodes>

     

     

    </telerik:RadTreeNode>

     

     

    </Nodes>

     

     

    </telerik:RadTreeNode>

     

     

    </Nodes>

     

     

    <CollapseAnimation Type="OutQuint" Duration="100"></CollapseAnimation>

     

     

    <ExpandAnimation Duration="100"></ExpandAnimation>

     

     

    </telerik:RadTreeView>

     

     

    </div>

     

     

    </form>

     

    </

     

    body>

     

    </

     

    html>

     

  2. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 20 Nov 2008 Link to this post

    Hello Russell,

    Two things are required in order for the keyPressing event to fire in FireFox:
    1. The TabIndex property of RadTreeView should be set so it can receive the focus
    2. The TreeView should be focused (for example by pressing the tab key until the "focus" box appears around the treeview).
    You can also focus the treeview when the user clicks a node like this:

    <script>
    function focusTreeView(sender, args)
    {
        sender.get_element().focus();
    }
    </script>

        <telerik:RadTreeView ID="RadTreeView1" runat="server" EnableDragAndDrop="True" Skin="Outlook"
    OnClientKeyPressing="test" TabIndex="1" OnClientNodeClicked="focusTreeView">
    Regards,
    Albert
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top