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

Edit Mode OnLoad

2 Answers 77 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Damon
Top achievements
Rank 1
Damon asked on 04 Jun 2010, 05:10 AM
Hi,

Is there any way to get radeditor to load in preview mode with design mode still enabled in the server side code?

Cheers
Damon

2 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 04 Jun 2010, 08:00 AM
Hello Damon,

You can load RadEditor in Preview mode using the following JavaScript 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>

You can set RadEditor in Preview mode only on the client side. In order to achieve your scenario you should import this script 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.

Kind 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
Damon
Top achievements
Rank 1
answered on 07 Jun 2010, 01:40 AM
Hi Rumen,

Thanks for the info, it helped greatly. I ended up using the below example to solve my issue of the radeditor returning to preview mode on postback.

Javascript:
function treNotesLoad(editor,args) {  
    var Postback = document.getElementById("<%=csPostback.ClientID%>");  
 
    if (Postback.value == "N") {  
        editor.set_mode(4);  
    }  

HTML:
<input type="hidden" id="csPostback" name="csPostback" runat="server" /> 

VB.NET
Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
 
    If Not IsPostBack() Then 
 
        ' Set the client side postback indicator hidden to NO  
        ' Used to allow javascript to tell if the page is postback  
        csPostback.Value = "N" 
 
    Else 
 
        ' Set the client side postback indicator hidden to YES  
        ' Used to allow javascript to tell if the page is postback  
        csPostback.Value = "Y" 
 
    End If 
 
End Sub 

Thanks again for the information!
Cheers
Damon
Tags
Editor
Asked by
Damon
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Damon
Top achievements
Rank 1
Share this question
or