Modelsフォルダにクラスを作成して、MyViewModelという名前にして、そのクラスにユーザーが編集する必要がある6つのプロパティをすべて定義する必要があります。 ビューを作成すると、レビューアクションにポストバックするように定義されたフォーム要素内にすべての入力フィールドが表示されます。あなたのビューの重要な一部で、次のようになります。MyControllerクラスで
@model MyViewModel
@using (Html.BeginForm("Review", "MyController"))
{
//here there's your input field
@Html.TextBoxFor(m => m.prop1)
// and so on
}
、あなたのレビュービューで、
public ActionResult Review(MyModel mm)
{
if (ModelState.IsValid)
{
return View(mm);
} else return RedirectToAction("Create");
}
そして最後に、次のように定義レビューの方法があるでしょう、あなたは'LL持っている:
public class ViaggioController : Controller
{
public ActionResult Create()
{
var emptyModel = new MyViewModel();
return RedirectToAction("Edit", new { mm = emptyModel });
}
public ActionResult Edit(MyViewModel mm)
{
return View(mm);
}
public ActionResult Review(MyViewModel mm)
{
if (ModelState.IsValid)
{
return View(mm);
}
else
return RedirectToAction("Create");
}
}
:
@model MyViewModel
//show up all the field to be reviewed
@Html.DisplayFor(m=>m.prop1)
//and so on
// now a form to pastback again all the data to the edit page
@using (Html.BeginForm("Edit", "MyController"))
{
//here there's your hidden field
@Html.HiddenFor(m => m.prop1)
// and so on
<input type="submit" value="Re-edit the fields"/>
}
あなたのコントローラクラスMyControllerは、次のコードを持っています
PartialViewはシナリオを実装するのに十分です。 –