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

How to make a RadEditor read only

5 Answers 543 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Randall
Top achievements
Rank 2
Randall asked on 30 Jul 2008, 09:05 PM
Hello,

I have RadEditor (Q2 2008 version 2008.1 619) and I want to know how to make the contents read only.

I searched your forums and found references to the Editable and HasPermissions properties, but these appear to be for a previous version.  I also found some JavaScript code to set the .EnableEditing property from client-side.  This also appears to be for a newer version.

What is the proper way to set the RadEditor to read only in my version?

Thanks,

Randall Price

5 Answers, 1 is accepted

Sort by
0
Todd Anglin
Top achievements
Rank 2
answered on 31 Jul 2008, 12:25 AM
Randall-

Sorry to hear you're having trouble finding your answer. To make the Editor read-only, simply set the "Enabled" property to false. You can see a live demo of the property in action here:


Hope that helps!

-Todd
0
Priya
Top achievements
Rank 1
answered on 17 Feb 2009, 07:37 AM
Sir,

I too using the latest version,so i dont hav the 'haspermission' property for radeditor.
I set the radeditor readonly by setg enabled=false
But the prbm is

I need the facility to print.So i need the print tool button visible..
Hw it is possible..any hope...

Plz help me...
thanks...
0
Rumen
Telerik team
answered on 17 Feb 2009, 08:06 AM
Hi Priya,

The idea is to get a reference to the DIV where the non-editable editor renders its content, obtain the content and print it using the browsers print() method. Here is an example:

<telerik:RadEditor runat="server" 
     ID="RadEditor1" 
     Enabled="false">  
     <Content> 
        <strong>this is sample text for printing</strong> 
     </Content> 
</telerik:RadEditor>  
<input onclick="javascript:PrintContent(); return false;" src="http://www.telerik.com/DEMOS/ASPNET/RadControls/Editor/Skins/Default/buttons/Print.gif" type="image" value="Print" /> 
<script type="text/javascript"
var wrapperDiv = document.getElementById("RadEditor1"); 
  
function PrintContent() 
    var printIframe = document.createElement("IFRAME"); 
    document.body.appendChild(printIframe); 
    var printDocument = printIframe.contentWindow.document; 
    printDocument.designMode = "on"
    printDocument.open(); 
    printDocument.write("<html><head></head><body>" + wrapperDiv.innerHTML + "</body></html>"); 
    printIframe.style.position"absolute"
    printIframe.style.top = "-1000px"
    printIframe.style.left"-1000px"
     
    if (document.all) 
    { 
        printDocument.execCommand("Print", null, false); 
    } 
    else 
    { 
        printDocument.contentWindow.print(); 
    } 
</script>  

You can download a sample project from here.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Krishnakanth
Top achievements
Rank 1
answered on 17 Feb 2009, 01:50 PM
Hi Rumen,
We are facing problem with rad editor.
we need to capture the content(new) of the Rad Editor in the paste command but we are not able to do this.
in which event we can be able to capture the new value.


Thanks in advance.
Regards,
Krishnakanth.E
0
Rumen
Telerik team
answered on 20 Feb 2009, 12:18 PM
Hi Krishnakanth,

In the upcoming Q1 2009 "Futures" release of RadControls for ASP.NET AJAX, the OnClientPasteHtml event of RadEditor will be fired when the onpaste browser event is executed. This will allow the developer to obtain and modify / clean only the pasted, but not the whole content inside the editor.

Here is a sample example that demonstrates how to attach to the Paste command:
 
<script type="text/javascript"
function OnClientPasteHtml(sender, args) 
    var commandName = args.get_commandName(); 
    var value = args.get_value(); //this is the pasted content 
    if (commandName == "Paste") 
    { 
           alert("original pasted content: " + value); 
            var newContent = "modified content"; //write here a regular expression that will strip the <h1><h2><h3>, etc tags  
            alert("modified pasted content" + newContent); 
            args.set_value(newContent);  //insert the modified content in the editor 
     } 
</script> 
<telerik:RadEditor runat="server" 
    OnClientPasteHtml="OnClientPasteHtml" 
    ImageManager-ViewPaths="~/" 
    ID="RadEditor1"
</telerik:RadEditor>    


The onpaste event will be executed only when the StripFormattingOptions property is not set to NoneSupressCleanMessage, because then the editor does not execute any code to handle the pasted content and it is pasted without modifications by the browser itself.


Kind regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Editor
Asked by
Randall
Top achievements
Rank 2
Answers by
Todd Anglin
Top achievements
Rank 2
Priya
Top achievements
Rank 1
Rumen
Telerik team
Krishnakanth
Top achievements
Rank 1
Share this question
or