I want to have custom Html.DateTimePickerFor(a => a.Fields[0].Id, value)
so the result should be like this:
<div name="Fields[0].Id"></div>
Currently I use Html.DatetimePicker("Fields[0].Id", value) and it works perfectly, but I wan to generate dynamic name.
So the question is how to set correct "name" attribute?
Try this. It works for me.
The magic comes from
System.Web.Mvc.ExpressionHelper.GetExpressionText(). Once you have the name from your expression, you can apply it to your div.GetExpressionText()