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

Reference to Editor from JS file included

1 Answer 36 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Gian Carlo Zamboni
Top achievements
Rank 1
Gian Carlo Zamboni asked on 09 Sep 2008, 01:54 PM
qwe


 
<form id="form1" runat="server"
    <asp:ScriptManager ID="ScriptManager1" runat="server"
    </asp:ScriptManager> 
    <div> 
      <telerik:RadEditor ID="RadEditor1" runat="server" Width="680px" Height="550px" AllowScripts="True" 
        Skin="Default2006" Language="es-CL" 
        ToolsFile="editor/ToolsFile.xml"
      </telerik:RadEditor> 
    </div> 
    <asp:ImageButton ID="ibt1" runat="server" OnClientClick="muestraID()" /> 
    <asp:ImageButton ID="ibt2" runat="server" OnClientClick="muestraIDFromJSFile()" /> 
 
    <script type="text/javascript" language="javascript"
      function muestraID() 
      { 
         var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client object 
         alert(editor.get_id()); //returns RadEditor Client ID 
         return; 
      } 
    </script> 
    <script type="text/javascript" language="javascript" src="test.js"></script> 
  </form> 

function muestraIDFromJSFile() 
   var editor = $find("<%=RadEditor1.ClientID%>"); 
   alert(editor.get_id());  

The reference to editor, doesn't work from a JS file. Im migrating from the old Edtiro (RadControls) and it workd before.

Any ideas?

1 Answer, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 11 Sep 2008, 01:39 PM
Hi Gian,

When your code is in a JS file, it is not parsed by the .NET engine which means that the server code is not executed and the client ID cannot be resolved - this is a general ASP.NET AJAX issue.

The solution that we can suggest is to use a global variable that is set either in the system client pageLoad function or in some control event, such as the editor's OnClientLoad.



Sincerely yours,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Editor
Asked by
Gian Carlo Zamboni
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Share this question
or