@using (Html.BeginForm())
{
@Html.Editor(ViewBag.Task1,"Task1");
@Html.Editor(ViewBag.Task2,"Task2");
<input type="submit" value="Save">
}
像这样。它显示我的错误
答案 0 :(得分:1)
@Html.Editor
的第一个参数是string
,因此如果您要渲染值为ViewBag.Task1
的文本框,请使用
@Html.Editor("Task1");
答案 1 :(得分:0)
i found the answer of my question, i can declare string variable as viewbag.somedata and i can use this variable in editor
here:
@{string task1 = ViewBag.Task1;string task2 = ViewBag.Task2}
@using (Html.BeginForm())
{
@Html.Editor(task1,"Task1");
@Html.Editor(task2,"Task2");
<input type="submit" value="Save">
}