English 中文(简体)
CKEditor and MVC
原标题:CKEditor and MVC
  • 时间:2009-10-11 23:11:49
  •  标签:

我已将模拟器纳入MVC asp.net项目。 我的问题是,这些投入被重新编码给控制员,然后在重新展示时,内容含有编码特性和标记; html。

我如何显示内部的html,仍然有文本编码。

任何建议都会受到赞赏。

问题回答

你们用什么来使案文成为现实? 如果你使用Html助手(例如Html.Textarea),则自动进行编码。

因此,如果你使用像CKEditor或TinyMCE这样的RTE,你可能不想这样做。 因此,仅凭手写成文法,或更妥善地写出你自己的文法推广法,限制/消除编码。

为什么你只能使用“底线”;%=%> 而不是“底线”;%:%> 符号:

我与CKeditor合并

<script type="text/javascript">

    $(document).ready(function () {
        CKEDITOR.replaceByClassEnabled = true;
        $( textarea.editor-basic, textarea.editor-standard, textarea.editor-richtext, textarea.editor-full ).each(function (i, textarea) {
            var config = {};
            if ($(textarea).hasClass( editor-basic )) {
                config = {
                    language:  en ,
                    toolbar:
                        [
                            { name:  basicstyles , items: [ Source ,  RemoveFormat ] }
                        ]
                };
            }
            else if ($(textarea).hasClass( editor-standard )) {
                config = {
                    language:  en ,
                    toolbar:
                        [
                            { name:  basicstyles , items: [ Source ,  Bold ,  Italic ,  Underline ,  Strike ,  Subscript ,  Superscript ,  - ,  RemoveFormat ] }
                        ]
                };
            }
            else if ($(textarea).hasClass( editor-richtext )) {
                config = {
                    language:  en ,
                    toolbar:
                        [
                            { name:  basicstyles , items: [ Source ,  Bold ,  Italic ,  Underline ,  Strike ,  Subscript ,  Superscript ,  - ,  RemoveFormat ] },
                             / ,
                            { name:  colors , items: [ TextColor ,  BGColor ,  Maximize ,  ShowBlocks ] },
                             / ,
                            { name:  fonts , items: [ Link ,  Styles ,  Format ,  Font ,  FontSize ] }
                        ]
                };
            }
            else if ($(textarea).hasClass( editor-full )) {
                config = {
                    language:  en ,
                    height:  500px ,
                    toolbar:
                        [
                            { name:  document , items: [ Source ,  - ,  Save ,  NewPage ,  DocProps ,  Preview ,  Print ,  - ,  Templates ] },
                            { name:  clipboard , items: [ Cut ,  Copy ,  Paste ,  PasteText ,  PasteFromWord ,  - ,  Undo ,  Redo ] },
                            { name:  editing , items: [ Find ,  Replace ,  - ,  SelectAll ,  - ,  SpellChecker ,  Scayt ] },
                             / ,
                            { name:  basicstyles , items: [ Bold ,  Italic ,  Underline ,  Strike ,  Subscript ,  Superscript ,  - ,  RemoveFormat ] },
                            {
                                name:  paragraph , items: [ NumberedList ,  BulletedList ,  - ,  Outdent ,  Indent ,  - ,  Blockquote ,  CreateDiv ,
                                     - ,  JustifyLeft ,  JustifyCenter ,  JustifyRight ,  JustifyBlock ,  - ,  BidiLtr ,  BidiRtl ]
                            },
                            { name:  links , items: [ Link ,  Unlink ,  Anchor ] },
                            { name:  insert , items: [ Image ,  Flash ,  Table ,  HorizontalRule ,  Smiley ,  SpecialChar ] },
                            { name:  styles , items: [ Styles ,  Format ,  Font ,  FontSize ] },
                            { name:  colors , items: [ TextColor ,  BGColor ,  Maximize ,  ShowBlocks ] }
                        ]
                };
            }
            else {
                return;
            }
            CKEDITOR.replace(textarea.id, config);
        });
        $( textarea.editor-basic, textarea.editor-standard, textarea.editor-richtext, textarea.editor-full ).each(function (i, textarea) {
            if (!$(textarea).hasClass( langdefault )) {
                $( #cke_  + textarea.id).hide();
            }
        });
        $( .sort_up, .sort_down ).click(function () {
            var thisrow = $(this).parent().parent().parent();
            if ($(this).hasClass( sort_down )) {
                if (thisrow.next().find( .sort_up ).length > 0) {
                    thisrow.next().after(thisrow);
                }
            }
            else {
                if (thisrow.prev().find( .sort_up ).length > 0) {
                    thisrow.prev().before(thisrow);
                }
            }
            thisrow.parent().find( tr ).removeClass( alternate-row );
            thisrow.parent().find( tr:odd ).addClass( alternate-row );
            updateOrders();
            return false;
        });
        $( .sortable ).tableDnD({
            onDrop: function (table, row) {
                $(table).find( tr ).removeClass( alternate-row );
                $(table).find( tr:odd ).addClass( alternate-row );
                updateOrders();
            }
        });

        $(".form-reset").bind("click", function () {
            $("input[type= text ], textarea").val("");
            for (var i in CKEDITOR.instances) {
                CKEDITOR.instances[i].setData("");
            }
        });
    });

</script>
<!-- in view page -->
<textarea name="desc" id="desc" class="form-textarea2 editor-basic"><%=Html.Encode(ViewBage.desc) %></textarea>




相关问题
热门标签