How to make a RadEditor read only

6 posts, 0 answers
  1. Randall
    Randall avatar
    54 posts
    Member since:
    Jun 2008

    Posted 30 Jul 2008 Link to this post

    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
  2. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 30 Jul 2008 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Priya
    Priya avatar
    144 posts
    Member since:
    Jul 2008

    Posted 17 Feb 2009 Link to this post

    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...
  5. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 17 Feb 2009 Link to this post

    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.
  6. Krishnakanth
    Krishnakanth avatar
    5 posts
    Member since:
    Jan 2009

    Posted 17 Feb 2009 Link to this post

    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
  7. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 20 Feb 2009 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017