Error: Unable to get value of the property 'set_mode': object is null or undefined

3 posts, 0 answers
  1. Michael Hurse
    Michael Hurse avatar
    20 posts
    Member since:
    Jun 2008

    Posted 17 Oct 2011 Link to this post

    Hi

    I am trying to change the mode of my radeditor to read only using client-side code. I did try modifying the enableEditing property but got the same result. On loading my page I want to be able to check the value of a hidden field and if it is 1 then set the editor into preview mode. If the hidden field is 0 then the editor should go into edit mode. I haven't got that far because the editor is giving inconsistent results. I can't get past just unconditionally setting the mode. Sometimes it works and sometimes I get the error in this thread title. It looks like the editor hasn't fully loaded in time for my onload javascript function. The relevant code is below. Please advise.

    thx Michael

     


    <body
    onload="LoadPage();">



    function LoadPage() 

     

    var editor = $find("<%=txtVisitNotes.ClientID%>");

    editor.set_mode(1);
    }

  2. Rumen
    Admin
    Rumen avatar
    14431 posts

    Posted 17 Oct 2011 Link to this post

    Hello Michael,

    You can try the following two approaches:

    - use the pageLoad() ajax event insead of the onload event, e.g.

    function pageLoad()
    {
          var editor = $find("<%=txtVisitNotes.ClientID%>");
          editor.set_mode(1);
    }



    - OR use the OnClientLoad event of RadEditor to change the mode:

    <telerik:RadIEditor OnClientLoad= "OnClientLoad" ...
    <script type="text/javascript>
    function OnClientLoad(editor)
    {
          editor.set_mode(1);
    }
    </script>


    Greetings,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. Michael Hurse
    Michael Hurse avatar
    20 posts
    Member since:
    Jun 2008

    Posted 26 Oct 2011 Link to this post

    Thanks Rumen - option 2 worked perfectly
    Michael
Back to Top