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

RadEditor

2 Answers 62 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
laila
Top achievements
Rank 1
laila asked on 16 Mar 2009, 12:57 PM
Hi, how to set the focus into RadEditor control when the page is loaded?

Actually i tried focus method and the following code given in the documentation
. Can anybody please tel me how to set the focus for radeditor ..so that focus will be inside the radeditor when the Page is loaded ..
Thanks in advance


<
body onload="SetFocusOnTextBox();">
   
<form id="form1" runat="server">
   
<asp:ScriptManager id="ScriptManager" runat="server"/>                              
   
<telerik:radeditor runat="server" ID="RadEditor1">
       
<Content>
           
Here is sample content!
       
</Content>
   
</telerik:radeditor>
   
<input type="text" id="text"/>
   
<input type="button" value="Set Focus On RadEditor" onclick="SetFocusOnRadEditor()" />
   
<script type="text/javascript">
   
function SetFocusOnRadEditor()
   {
       var editor = $find("
<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client object
       editor.setFocus(); //set the focus on the the editor
   }
   function SetFocusOnTextBox()
   {
       var editor = $get("text"); //get a reference to the input textbox with id text
       editor.focus(); //set the focus on the the textbox
   }
   
</script>
   
</form>
</
body>

2 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 16 Mar 2009, 03:40 PM
Hello Laila,

I suggest to use the RadEditor's OnClientLoaded event to set the focus and to do it with a little timeout, e.g as shown below:

       <script type="text/javascript">  
   function OnClientLoad(sender, args)  
   {  
      //set the focus on the the editor  
      setTimeout(function(){  
      sender.setFocus();  
 
      }, 100);   
   }  
   

You can also test whether even timeout of 0 ms can do the trick because it is very probable but depends on the loading time of your page.

Best wishes,
Svetlina
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
laila
Top achievements
Rank 1
answered on 19 Mar 2009, 04:25 AM
Hi,

 Thanks for your reply. It is working fine...


Regards,
Laila
Tags
General Discussions
Asked by
laila
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
laila
Top achievements
Rank 1
Share this question
or