I don't know if this has happened to other people, but it has happened to me: the xxxFor methods in InputExtensions (TextBoxFor, LabelFor, etc) generate HTML content where the id and name attributes come from the property name. There is a problem if we use TextBoxFor, for example, on a view, two times with the same property names, even if they come from different classes.
So, I propose an overload (or the actual substitution of the current methods) for each of these methods that takes a prefix and applies it to the id attribute (not the name one, since this is required for binding to the model), such as:
public static MvcHtmlString TextBoxFor<TModel, TProperty>(
this HtmlHelper<TModel> htmlHelper,
Expression<Func<TModel, TProperty>> expression,
String prefix = null
)
This way, we avoid id clashes on the HTML, while preserving binding compatibility.
Comments: Any news on this? Any chance this may be implemented? Thanks!
So, I propose an overload (or the actual substitution of the current methods) for each of these methods that takes a prefix and applies it to the id attribute (not the name one, since this is required for binding to the model), such as:
public static MvcHtmlString TextBoxFor<TModel, TProperty>(
this HtmlHelper<TModel> htmlHelper,
Expression<Func<TModel, TProperty>> expression,
String prefix = null
)
This way, we avoid id clashes on the HTML, while preserving binding compatibility.
Comments: Any news on this? Any chance this may be implemented? Thanks!