0

我试着在这里使用这个例子

<%: Html.TextBoxFor(model => model.MyList[0].FirstName, model.MyList[0].IsEnabled ? (object)new { disabled = "disabled" } : new { })%>

但这给了我一个错误

“名称模型在当前上下文中不存在”

有没有办法在 vanilla asp.net MVC 3 中不使用 if else 条件来做到这一点?

谢谢你的时间...

4

2 回答 2

1

我解决了这个问题:我应该使用传递给视图的实际模型。注意 Caps 在第二个参数上的变化。

<%: Html.TextBoxFor(model => model.MyList[0].FirstName, Model.MyList[0].IsEnabled ? (object)new { disabled = "disabled" } : new { })%>
于 2012-05-29T10:49:41.740 回答
0

快速检查此错误消息表明您的 web.config 可能已损坏。

MVC3 的当前上下文中不存在名称“模型”

于 2012-05-29T10:10:51.957 回答