$find("<%=RadEditor1.ClientID%>") gives error

11 posts, 0 answers
  1. maggi
    maggi avatar
    58 posts
    Member since:
    Mar 2007

    Posted 27 May 2009 Link to this post

    Hello ,

           I am trying to paste an html in radeditor using

    <script type="text/javascript">  
         var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client object  
         editor.set_html('test');  
    </script>

    but when i try to find the editor using $find it gives error $find is not defined. plz help.

    Regards
    maggi

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 May 2009 Link to this post

    Hi Maggi,

    Can you try the following approach by using the pageLoad() method to set the editor content?

    JavaScript:
     
    <script type="text/javascript">   
    function pageLoad() 
        var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client object   
        editor.set_html('test');     
    </script> 
    Could you please inform us exactly which version of RadEditor/RadControl are you using (if this does not help)?

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. maggi
    maggi avatar
    58 posts
    Member since:
    Mar 2007

    Posted 30 May 2009 Link to this post

    Hi Shinu,

       I think my version of editor might be the reason this code does not work for me i am using 7.1.0.0 version of the editor. Is there any other way of copying the text in a radeditor from the client side.

    Thanks,
    maggi
  5. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 30 May 2009 Link to this post

    var currentEditor = $find("EditorClientID") -  is related to RadEditor for ASP.NET AJAX.

    If you want ot get a reference to RadEditor for ASP.NET you should use GetRadEditor method, e.g.
    var currentEditor = GetRadEditor("RadEditor1");

     

    currentEditor.SetHtml("text")

     

     

  6. Netfinity
    Netfinity avatar
    3 posts
    Member since:
    Nov 2006

    Posted 16 Jul 2009 Link to this post

    I am using the following javascript in my Sitefinity site:

    protected void Page_Load(object sender, EventArgs e)
        {
            string script = string.Format(@"<script type='text/javascript' language='javascript'>
                $(document).ready(function() {{
                    var quoteEditor = $find('{0}');

                    quoteEditor.set_html('');
                }});
                </script>", tbQuote.ClientID);

            Page.ClientScript.RegisterStartupScript(Page.GetType(), "removeQuote", script);
        }

    The issue is that this works perfectly (as usual) on Firefox but I get a javascript error in IE 7

    I am using JQuery throughout my site and I am note sure if this is related. I have already tried GetRadEditor() .SetHtml(), $telerik.$ instead of just $, and I have tried using jQuery.noConflict(). All to no avail.

    IE is the bane of my life can someone please provide a work around for this?

  7. Georgi
    Admin
    Georgi avatar
    31 posts

    Posted 21 Jul 2009 Link to this post

    Hello Netfinity,

    How, and where exactly do you place this code? Are you creating a code behind of some of the existing forum controls/views?
    Is it an option for you to change the RadEditor text from the Server side? You can do this by creating a custom control inheriting from the one having the editor, and then find the editor by using base.FindControl(). The custom control class should be placed in the App_Code directory and registered in Sitefinity as follows:
    <toolboxControls> 
    .. 
    <add name="Custom Forum Thread" section="Forums" type="Namespace.Class, App_Code" /> 
    .. 

    I hope this helps.

    Regards,
    Georgi
    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.
  8. Netfinity
    Netfinity avatar
    3 posts
    Member since:
    Nov 2006

    Posted 12 Aug 2009 Link to this post

    I was trying to execute this code in an added code behind on the /Sitefinity/ControlTemplates/Forums/EditPost.ascx template.

    The reason for this is to clear or reset the content in the tbQuote RadEditor which contains the previous post's content. In other words I am trying to completely turn off quotes in my Sitefinity site's forum.

    I found a much easier work around which I'll share:

        protected void Page_PreRender(object sender, EventArgs e)
        {
            tbQuote.Content = string.Empty;
        }

    Yes - I added this server side code instead
  9. Mahesh
    Mahesh avatar
    6 posts
    Member since:
    Jul 2013

    Posted 05 Jun 2014 in reply to Obi-Wan Kenobi Link to this post

    GetRadEditor is not working in IE 11.what will be the problem
  10. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Jun 2014 in reply to Mahesh Link to this post

    Hi Mahesh,

    I guess you want to access the RadEditor in JavaScript. Please try the below approach which works fine at my end.

    JavaScript:
    var currentEditor = $find("<%=RadEditor1.ClientID%>");

    Please elaborate your requirement if it doesn't help.
    Thanks,
    Shinu.
  11. Sujay
    Sujay avatar
    1 posts
    Member since:
    Jan 2016

    Posted 14 Apr in reply to maggi Link to this post

    Hey,

    $find doesn't work outside a function . I was having same problem you had.

  12. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 18 Apr Link to this post

    Hi Sujay,

    You can access IScriptControls such as ours at earliest in the Sys.Application.Load event. You can read more on the subject in the following help article that explains the different ways to get a client-side reference to our controls: http://docs.telerik.com/devtools/aspnet-ajax/general-information/get-client-side-reference.

    Regards,

    Marin Bratanov
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017