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

How can I open the editor in preview mode rather than design mode?

5 Answers 498 Views
Editor
This is a migrated thread and some comments may be shown as answers.
des white
Top achievements
Rank 1
des white asked on 26 Apr 2010, 12:05 PM
Id like the editor to load in preview mode. Currently the default is design mode and I cant see any way to change this.

Can anyone advice how to do this?

Just to be clear I want the design mode to still be availble to users...I just want is to open in the preview mode.

Many Thanks, Des

5 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 26 Apr 2010, 12:11 PM
Hi Des,

You can load the editor in the Preview mode on page load with this code:

<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>

If you don't like the Design and HTML modes, you can load the editor in Preveiw mode by setting the EditModes property to Preview, e.g.

<telerik:RadEditor ID="RadEditor1" EditModes="Preview" runat="server"></telerik:RadEditor>

Best regards,
Rumen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Timothy Kruszewski
Top achievements
Rank 1
answered on 03 Nov 2010, 05:40 PM
How can this be done server side via C# code?  Or better yet we store a cookie with the setting of HTML or DESIGN and when the page loads the editor should have the HTML view or DESIGN view selected but all tabs(Design, Html and Preview) should still be available for selection.

Thanks
0
Rumen
Telerik team
answered on 03 Nov 2010, 07:16 PM
Hi Timothy ,

You can set RadEditor in Preview mode only on the client side. In order to achieve your scenario you should import the provided JavaScript code using one of the server-side methods: Page.RegisterStartupScript or Page.RegisterClientScriptBlock.

More information is available in this blog post: Executing JavaScript function from server-side code.


All the best,
Rumen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Timothy Kruszewski
Top achievements
Rank 1
answered on 04 Nov 2010, 09:52 PM
Could you please show me a C# code sample?
0
Rumen
Telerik team
answered on 05 Nov 2010, 12:48 PM
Hi Timothy,

Sure, here is the C# code:

protected void Page_Load(object sender, EventArgs e)
{
    RadEditor1.OnClientLoad = "OnClientLoad";
 
    string js = @" 
    <script language='javascript'
        function OnClientLoad(editor, args) {
            setTimeout(function()
            {
                editor.set_mode(4);
            }, 100);
        }
    </script>";
    ClientScript.RegisterClientScriptBlock(this.GetType(), "myscriptkey", js);
}


Regards,
Rumen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Editor
Asked by
des white
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Timothy Kruszewski
Top achievements
Rank 1
Share this question
or