Format Code Block dialog

4 posts, 0 answers
  1. Dan
    Dan avatar
    40 posts
    Member since:
    Mar 2009

    Posted 12 Dec 2011 Link to this post

    HI there,

    I am using the RadEditor to allow my users to edit the content that they would like to post to their website.  I just saw the new Format Code Block dialog and was hoping that I could use that to allow them to enter specific CSS styles or javascript that they wanted to use on a particular page.  However, the code block just displays on their content page along with all the other rendered html.

    Am I missing something or is this dialog only intended to be used for things like this forum where people can submit code snippets?  The examples that I can find only show how to use the dialog within the editor, not how those code blocks can actually be used to render the html differently (i.e. assigning styles).

    I hope that I am explaining myself clearly.  Thanks in advance for your help.
    Dan
  2. Rumen
    Admin
    Rumen avatar
    14462 posts

    Posted 14 Dec 2011 Link to this post

    Hello Dan,

    Yes, the only purpose of the Format Code Block tool is to insert code snippets with defined styles. The tool does not offer the ability to import your own styles and modify the appearance of the snippets.

    Best wishes,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. Dan
    Dan avatar
    40 posts
    Member since:
    Mar 2009

    Posted 14 Dec 2011 Link to this post

    Hi Rumen,

    I don't think that I explained what I am looking for.

    I have a content management site that allows the user to create content using the RadEditor.  The html generated from the editor is saved to a database and then rendered to their website.

    I have some advanced users who would like to add css styles and possibly java script to the content that they enter in the editor.  Currenty I believe that they are just going to the HTML tab in the editor and pasting this extra code in there.  I was hoping that the Format Code Block tool would allow them to add this extra code from the Design tab.  The issue is that the <div> statements that format the code block in the design tab are also saved in the radeditor1.content value and so are being written to the database and rendering on the website.

    Somehow I need to be able to take what they enter in the code block and just save that along with the other content. 

    I hope this makes things clearer.  Let me know if you need more explanation.

    Thanks.
    Dan
  4. Rumen
    Admin
    Rumen avatar
    14462 posts

    Posted 19 Dec 2011 Link to this post

    Hello Dan,

    You can use the PasteHtml tool to paste script and styles in the editor from Design mode as shown in the following video: http://screencast.com/t/OhBQXpspTxu.

    There are two important things that you should now about this operation:

    1) You should place some content before the script / style tags, because in other case the IE browser will strip them.
    2) You should disable the RemoveScripts filter of RadEditor, which is enabled by default.

    Test RadEditor's declaration:
    <telerik:RadEditor ID="RadEditor1" runat="server">
        <Tools>
            <telerik:EditorToolGroup>
                <telerik:EditorTool Name="PasteHtml" />
            </telerik:EditorToolGroup>
        </Tools>
    </telerik:RadEditor>
    <script type="text/javascript" runat="server">
    public void Page_Load(object sender, EventArgs e)
        {
            RadEditor1.DisableFilter(EditorFilters.RemoveScripts);
        }
    </script>


    Test Content:
    test    <script type="text/javascript">
            function Test() {
                alert(1);
            }
        </script>
    <style type="text/css">
            .redText
            {
                color: Red;
            }
        </style>


    All the best,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top