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

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

2 Answers 68 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Michael Hurse
Top achievements
Rank 1
Michael Hurse asked on 17 Oct 2011, 02:09 PM
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 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 17 Oct 2011, 02:34 PM
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
0
Michael Hurse
Top achievements
Rank 1
answered on 26 Oct 2011, 11:50 PM
Thanks Rumen - option 2 worked perfectly
Michael
Tags
Editor
Asked by
Michael Hurse
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Michael Hurse
Top achievements
Rank 1
Share this question
or