Default color - RadEditor

2 posts, 0 answers
  1. imad
    imad avatar
    1 posts
    Member since:
    Sep 2018

    Posted 20 Sep 2018 Link to this post

    Hello,

    I want to make a default color in toolbar for the color and background : when the user select a text, and click on the buton of color,that will make my dafault color

    i do this

    <telerik:EditorTool Name="ForeColor"     Value="red" />

    but when i select the text and try to make my color by default ,that open the dialog color and not colorized my text

     

    Thank you

  2. Rumen
    Admin
    Rumen avatar
    14466 posts

    Posted 25 Sep 2018 Link to this post

    Hi Imad,

    If you want to apply a default color to the content area check this article and demo: Set Editor Background and Color and Customize Content Area.

    If you want to change the pallet colors see this article: Colors.

    To programmatically execute the ForeColor or BackColor commands use the fire client-side method:

     editor.fire('ForeColor', { value: "orange" });

    Here is an example how to set the forecolor to red when clicking on the ForeColor tool:

    <script type="text/javascript">
        function OnClientLoad(editor, args) {
            var foreColor = editor.getToolByName("ForeColor");
            $telerik.$(foreColor.get_element()).click(function () {
                foreColor.set_value('red');
                editor.fire('ForeColor', { value: "red" });
            });
        }
         
    </script>
    <telerik:RadEditor runat="server" OnClientLoad="OnClientLoad" ID="RadEditor1">
        <Content>some test content</Content>
    </telerik:RadEditor>

    Here is another example how to set the default color when start typing in the content area:

    <script type="text/javascript">
        function OnClientLoad(editor, args) {
            var element = document.all ? editor.get_document().body : editor.get_document();
            $telerik.addExternalHandler(element, "click", function (e) {
                editor.fire('ForeColor', { value: "red" });
            });
        }
    </script>
    <telerik:RadEditor runat="server" OnClientLoad="OnClientLoad" ID="RadEditor1">
        <Content>test content</Content>
    </telerik:RadEditor>


    Regards,
    Rumen
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top