Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.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# 如何在MVC中构造表单?_C#_Asp.net_Asp.net Mvc_Asp.net Mvc 4 - Fatal编程技术网

C# 如何在MVC中构造表单?

C# 如何在MVC中构造表单?,c#,asp.net,asp.net-mvc,asp.net-mvc-4,C#,Asp.net,Asp.net Mvc,Asp.net Mvc 4,我试图在MVC应用程序的视图(“编辑器”)中构造表单,但当用户按下提交按钮时,我会出错。我的表单有一个编辑器控件 我的编辑视图 如果我返回我的模型而不是“return(MyModel)”,则会在@model.Text处得到另一个错误“System.NullReferenceException” <textarea name="editor1" id="editor1" rows="400" cols="100"> @Model.Text </textarea> @范文

我试图在MVC应用程序的视图(“编辑器”)中构造表单,但当用户按下提交按钮时,我会出错。我的表单有一个编辑器控件

我的编辑视图 如果我返回我的模型而不是“return(MyModel)”,则会在@model.Text处得到另一个错误“System.NullReferenceException”

<textarea name="editor1" id="editor1" rows="400" cols="100">
@Model.Text
</textarea>

@范文

当submitform操作启动时,您的视图似乎位于错误的位置,在运行时无法找到!在跟踪中,您可以看到搜索的位置。自动执行此操作的最佳方法是右键单击操作并选择“添加视图”菜单项。除了那张表看起来还可以

哪个目录是您的SubmitForm html文件~/视图/?你能告诉我你的控制器名称吗?你在控制器中返回编辑器,所以你的视图必须是“editor.cshtml”。提交表单在视图文件夹中。控制器的名称为EditorController。根据下面的建议。我删除了我的视图并删除了SubmitForm操作,以便重新开始。我右键单击我的编辑器()操作选择添加视图。我现在不再有这个错误了。我注意到Editor()在显示视图时被调用,当我按下Save按钮时再次被调用。保存后,如何获取用户更改的数据?FormsCollection?我删除了我的视图并删除了SubmitForm操作以重新开始。我右键单击我的编辑器()操作选择添加视图。我现在不再有这个错误了。ThanksI注意到Editor()在显示视图时被调用,在我按下Save按钮时再次被调用。保存后,如何获取用户更改的数据?表格收集?
[HttpPost, ValidateInput(false)]
public ActionResult SubmitForm(FormCollection collection)
{
    string sText = collection[0].ToString();

    // save string from CKEditor

    return View("Editor");  //<-- I get the error here.
}
The view 'SubmitForm' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Edit/SubmitForm.aspx
~/Views/Edit/SubmitForm.ascx
~/Views/Shared/SubmitForm.aspx
~/Views/Shared/SubmitForm.ascx
~/Views/Edit/SubmitForm.cshtml
~/Views/Edit/SubmitForm.vbhtml
~/Views/Shared/SubmitForm.cshtml
~/Views/Shared/SubmitForm.vbhtml 
<textarea name="editor1" id="editor1" rows="400" cols="100">
@Model.Text
</textarea>