开发者

ASP.NET MVC strongly typed helpers generate wrong input nam when are used inside foreach

I've got a problem with ASP.NET mvc stongly typed helpers.

Here is example of wrong behavior:

<% foreach (var item in Model) { %>
   <开发者_C百科;%: Html.TextboxFor(m => item.Name) %>
<% } %>

will generate following inputs: <input name="item.Name".....

As you see generated name is wrong, because of wrong algorithm of extracting property name from lambda.

The only way to avoid this bug is to create PartialView and pass item as its context.

May be somebody knows other solutions?

Regards, Alexey Zakharov.


Why just not <%= Html.TextboxFor(item.Name) %> ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜