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

Editor takes focus

14 Answers 199 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Drew
Top achievements
Rank 1
Drew asked on 10 Apr 2008, 10:55 PM
I have a simple page that has a TextBox control and the RADEditor control. In Page_Load I'm giving the text box focus. In IE, the focus appears to be "taken" by the editor after the page has loaded. I can work around this so far only by forcing focus to the text box in client script with a setTimeout call using a high timeout value (at least 5000). I tried forcing focus to the text box in the OnClientLoad handler, but that didn't work. Please advise.

14 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 11 Apr 2008, 08:42 AM
Hi Drew,

What the editor actually does is similar to (but not exactly the same as) getting the focus. The editor just gets the page selection in order to attach its event handlers properly.

Here is an example how to set the focus to the textbox control:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<telerik:radeditor runat="server" OnClientLoad="OnClientLoad" ID="RadEditor1"></telerik:radeditor>
<script type="text/javascript">
function OnClientLoad(editor, args)
{
    setTimeout(function()
    {
        $get("TextBox1").focus();
    }, 100);
}
</script>

For your convenience I captured and attached a video demonstrating how this code works.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Drew
Top achievements
Rank 1
answered on 11 Apr 2008, 02:23 PM
As I said in my original post, I have to use an unacceptably high timeout value for that approach. If you like, I can upload a video of the code you supplied _not_ working.

Instead, I've overridden the prototype of Telerik.Web.UI.RadEditor.initialize and changed your text range code so that it no longer takes focus.

Thanks for your help.
0
Ilia
Top achievements
Rank 1
answered on 17 Jun 2008, 05:12 PM
Hello Drew,

Could you provide more details of your solution?
0
Tervel
Telerik team
answered on 18 Jun 2008, 07:06 AM
Hi,

We were able to improve on the situation and the coming Q2 SP2 update scheduled for this Thursday will feature a significant improvement in the behavior. My suggestion would be to wait for it and give it a try.

Then, in case you still want to tackle the code yourself, we will post information how and what method to override.


Sincerely yours,
Tervel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ilia
Top achievements
Rank 1
answered on 22 Jul 2008, 07:57 PM
editor seem to be still grabbing focus in 2008.2.708.20
which causes pages with couple editors stacked vertically and vertical scrollbar to jump around on load.
0
Petio Petkov
Telerik team
answered on 23 Jul 2008, 02:28 PM
Hello Ilia,

We improved this behavior and the improvement is included in the latest official release(2008.2.723). We have an online example with five editors here:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Editor/Examples/ToolProvider/DefaultCS.aspx
We tried to reproduce the problem that you have in the example above and everything seems to be OK.


All the best,
Petio Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Andreas
Top achievements
Rank 1
answered on 11 Sep 2008, 02:53 PM
Never tried the 2008.2.723 version, but in the 2008.2.826 version, the problem is back/still there.
Even the online example has the problem.
Only IE, Firefox works fine.

Regards
Andreas
0
George
Telerik team
answered on 15 Sep 2008, 01:12 PM
Hi Andreas,

Could you please clarify, are you able to reproduce the problem using the previously provided by Petio online demo? I tested it under IE and Firefox and everything works fine.

If you still experience the problem, please open a support ticket and send us a sample video that demonstrates the behavior. We will check the details and do our best to provide a solution.

Kind regards,
George
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Andreas
Top achievements
Rank 1
answered on 10 Oct 2008, 03:20 PM
In this simple sample, the textbox will not get focus in IE7 (works in Firefox):

test.aspx:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>

<!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>
    <asp:TextBox ID="txt" runat="server"></asp:TextBox>
    <telerik:radeditor runat="server" id="re" runat="server"></telerik:radeditor>
    </form>
</body>
</html>

test.aspx.vb:
Partial Class test
    Inherits System.Web.UI.Page

    Protected Sub test_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        txt.Focus()
    End Sub
End Class


For a short moment I can see that the textbox gets focus, but it looses it directly. If hiding the radeditor the textbox will get focus.
Using the version 2008.2.826.

Regards
Andreas



0
Rumen
Telerik team
answered on 10 Oct 2008, 03:44 PM
Hi Andreas,

You need to set the focus to the textbox in the OnClientLoad event of RadEditor with a small delay. For that purpose you can use the setTimeout javascript method, e.g.

function OnClientLoad()
{
   setTimeout(function()
   {
      document.getElementById("txt").focus(); //set the focus to the textbox with id txt1
   }, 300);
}


Best regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Andreas
Top achievements
Rank 1
answered on 13 Oct 2008, 06:55 AM
So what you are saying is that the built in WebControl.Focus() is broken if a RadEditor is visible on the page.

We are building dynamic dialogs where we are using the Focus() function to set focus on the correct control for the user.

Do you really mean that if one or more RadEditor happens to be visible on our dynamically created page, then we have to do this in the RadEditors OnClientLoad, and if no RadEditor was visible, then do it the normal way.

Will this be fixed in future version, so we can use the normal WebControl.Focus()? This would be a lot easier!!!

Regards
Andreas
0
Rumen
Telerik team
answered on 13 Oct 2008, 09:16 AM
Hi Andreas,

What the editor actually does is similar to (but not exactly the same as) getting the focus. The editor just gets the page selection in order to attach its event handlers properly. That is why you should set the focus after the editor's load using the OnClientLoad event. You can attach it on the server like this:

RadEditor1.OnClientLoad = "OnClientLoad"; // the OnClientLoad string is the name of a client side function

If our developers find a solution to fix this IE browser behavior, we will enhance the editor to not get the focus.

Best regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
tbellinger
Top achievements
Rank 1
answered on 23 Oct 2008, 02:06 PM
Andreas,
You are not alone with this issue.  I too have the same problem.  We are using the latest version of the RadEditor in each row of a multi-row gridview (sometimes up to 100 rows, but typically 8-12 rows) and internally only use IE within our company.  When the grid is put into a full edit mode (every row is editable), the page jumps because of this focus grabbing by the editor.  It's a problem because we cannot get the focus moved back to a regular textbox that precedes one of the editors.
0
Rumen
Telerik team
answered on 24 Oct 2008, 03:57 PM
Hi Tom,

Could you please, send us a sample working project that demonstrates the problem and we will try to provide a solution?


Best regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Editor
Asked by
Drew
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Drew
Top achievements
Rank 1
Ilia
Top achievements
Rank 1
Tervel
Telerik team
Petio Petkov
Telerik team
Andreas
Top achievements
Rank 1
George
Telerik team
tbellinger
Top achievements
Rank 1
Share this question
or