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

[Solved] Set Editor to Preview mode OnLoad?

7 Answers 147 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Andy Byrne
Top achievements
Rank 1
Andy Byrne asked on 06 Jan 2010, 10:08 PM
Is there a way to set the editor to preview mode when the page loads?  I've browsed the documentation and forums and can't find anything describing this.

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Jan 2010, 05:41 AM
Hello Andy Byrne,

Attach 'OnClientLoad' and set the mode in the handler for RadEditor.

JavaScript:
 
<script type="text/javascript"
    function OnClientLoad(editor, args) { 
        editor.set_mode(4); 
    } 
</script> 

-Shinu.
0
Rumen
Telerik team
answered on 07 Jan 2010, 07:36 AM
Hello Andy,

Information about the set_mode method is available in this article: set_mode.

You can also hide the other modes using the EditModes server property.

Sincerely,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Andy Byrne
Top achievements
Rank 1
answered on 07 Jan 2010, 02:38 PM
I am actually already using the code above by Shinu and it is in Preview mode.  The problem here is that the tools at the top of the editor are showing as active instead of disabled as they are when we normally click on preview mode.  Is there anyway to disable these in preview mode?  We're using code very similar to the demo on this site of a custom editor.
0
Accepted
Rumen
Telerik team
answered on 07 Jan 2010, 02:57 PM
Hi Andy,

Please, set a small time out and see whether this helps:

<telerik:RadEditor runat="server" ID="RadEditor1" OnClientLoad="OnClientLoad">
    <Content>Sample Content</Content>
</telerik:RadEditor>
<script type="text/javascript">
    function OnClientLoad(editor, args) {
        setTimeout(function()
        {
            editor.set_mode(4);
        }, 100);
    }
</script>

For your convenience I have attached my test project.

All the best,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Andy Byrne
Top achievements
Rank 1
answered on 07 Jan 2010, 03:21 PM
Setting the time out seems to have fixed the problem.  Any idea why this is necessary (in case we need to do something similar in the future)?
0
Rumen
Telerik team
answered on 07 Jan 2010, 03:30 PM
Hi Andy,

Actually, the toolbar icons were disabled on my end when programmatically switching to Preview mode even without this timeout. It is more likely something specific to your scenario, where the set_mode method is executed too early and the toolbar stays editable.

Best wishes,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Andy Byrne
Top achievements
Rank 1
answered on 07 Jan 2010, 03:48 PM
Makes sense -- thanks much for the help!

Andy
Tags
Editor
Asked by
Andy Byrne
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Rumen
Telerik team
Andy Byrne
Top achievements
Rank 1
Share this question
or