如何修复多行文本框的tinymce错误

时间:2016-12-31 13:19:33

标签: javascript jquery asp.net

我正在使用ASP.NET WebForm 我有一些问题与tinymce和多行文本框。 当我点击“提交”按钮时,我遇到了错误。 我使用了一些像trikes这样的三轮车:OnClientClick="tinyMCE.triggerSave(false,true);" 但它不起作用。 请告诉我一些解决方案。

 <div style="float: left; width: 100px;">
        <asp:Button ID="btnSubmit" runat="server" CssClass="btn btn-success" Text="<%$Resources:Buttons,Submit %>"
            OnClientClick="tinyMCE.triggerSave(false,true);" OnClick="btnSubmit_Click" />

    </div>


<script src="../Scripts/tinymce/tinymce.min.js" type="text/javascript"></script>

<script type="text/javascript" >
    tinyMCE.init({
        selector: "textarea",
         height: 500,
        plugins: [
          "advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker",
          "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
          "table contextmenu directionality emoticons template textcolor paste fullpage textcolor colorpicker textpattern"
        ],

        toolbar1: "newdocument fullpage | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect formatselect fontselect fontsizeselect",
        toolbar2: "cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | link unlink anchor image media code | insertdatetime preview | forecolor backcolor",
        toolbar3: "table | hr removeformat | subscript superscript | charmap emoticons | print fullscreen | ltr rtl | spellchecker | visualchars visualblocks nonbreaking template pagebreak restoredraft",

        menubar: false,
        toolbar_items_size: 'small',

        style_formats: [{
            title: 'Bold text',
            inline: 'b'
        }, {
            title: 'Red text',
            inline: 'span',
            styles: {
                color: '#ff0000'
            }
        }, {
            title: 'Red header',
            block: 'h1',
            styles: {
                color: '#ff0000'
            }
        }, {
            title: 'Example 1',
            inline: 'span',
            classes: 'example1'
        }, {
            title: 'Example 2',
            inline: 'span',
            classes: 'example2'
        }, {
            title: 'Table styles'
        }, {
            title: 'Table row 1',
            selector: 'tr',
            classes: 'tablerow1'
        }],

        templates: [{
            title: 'Test template 1',
            content: 'Test 1'
        }, {
            title: 'Test template 2',
            content: 'Test 2'
        }],
        content_css: [
          '//fast.fonts.net/cssapi/e6dc9b99-64fe-4292-ad98-6974f93cd2a2.css',
          '//www.tinymce.com/css/codepen.min.css'
        ]
    });

1 个答案:

答案 0 :(得分:0)

我相信您正面临着TinyMCE与ASP.NET Web Forms一起使用时出现的验证问题。我最终为自己的项目提供了以下解决方案。

tinyMCE.init({
    setup: function (editor) {          
        // Listen to change and keyup events and trigger save event
        editor.on('change', tinyMCE.triggerSave);
        editor.on('keyup', tinyMCE.triggerSave);
    },
    ... // Other options
});