Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何让YUI编辑器传递其内容_C#_Javascript_Asp.net_Asp.net Mvc_Yui - Fatal编程技术网

C# 如何让YUI编辑器传递其内容

C# 如何让YUI编辑器传递其内容,c#,javascript,asp.net,asp.net-mvc,yui,C#,Javascript,Asp.net,Asp.net Mvc,Yui,我正在尝试在asp mvc站点上使用YUI富文本编辑器,我正在使用此javascript代码 var myEditor = new YAHOO.widget.Editor('Body', { height: '300px', width: '522px', dompath: true, //Turns on the bar at the bottom animate: true //Animates the opening, closing and moving

我正在尝试在asp mvc站点上使用YUI富文本编辑器,我正在使用此javascript代码

var myEditor = new YAHOO.widget.Editor('Body', {
    height: '300px',
    width: '522px',
    dompath: true, //Turns on the bar at the bottom
    animate: true //Animates the opening, closing and moving of Editor windows
});
myEditor.render();

``

在这个区域

<div class="yui-skin-sam">
            @Html.TextAreaFor(model => model.Body, new { cols = "50", rows = 10 })
            @Html.ValidationMessageFor(model => model.Body)
        </div>

@Html.TextAreaFor(model=>model.Body,new{cols=“50”,rows=10})
@Html.ValidationMessageFor(model=>model.Body)
编辑器加载,但当我提交表单时,它的内容没有被传递。我一直收到一条验证消息,说如果表单中没有任何内容,则需要feild


有人知道我怎样才能让它以我想要的方式工作吗?

如果有人最终遇到这个问题,这里有一个解决方案

您可以尝试设置handleSubmit:true,如下所示

var myEditor = new YAHOO.widget.Editor('Body', {
height: '300px',
width: '522px',
dompath: true, //Turns on the bar at the bottom
animate: true, //Animates the opening, closing and moving of Editor windows
handleSubmit: true
})); myEditor.render()

编辑器将尝试连接自身,并自动调用MyEdit.saveHTML(),将内容填充回文本区域。如果像对我一样失败,请手动设置一个事件,如下所示

   YAHOO.util.Event.on('somebutton', 'click', function() {

myEditor.saveHTML();
alert("test");
});
其中somebutton是表单的提交按钮的名称


当您开始工作时,您将遇到的第二个问题是asp.net在您的模型中找到html标记时会出错。这是一个不同的问题,因此我不会在这里描述解决方案。

此外,我已经查看了源代码,文本区域的名称和id实际上是Body