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

Format Code Block dialog

3 Answers 171 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 12 Dec 2011, 11:22 PM
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

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 14 Dec 2011, 03:18 PM
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
0
Dan
Top achievements
Rank 1
answered on 14 Dec 2011, 08:29 PM
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
0
Rumen
Telerik team
answered on 19 Dec 2011, 02:54 PM
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
Tags
Editor
Asked by
Dan
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Dan
Top achievements
Rank 1
Share this question
or