views:

42

answers:

1

Hi guys,

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

Here is example of wrong behavior:

<% foreach (var item in Model) { %>
   <%: 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.

A: 

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

Sergey Osypchuk
There is no TextboxFor method that are not using lambda parameter.
Alexey Zakharov