In Html.Editor (technically EditorExtensions.Editor) there is an overload with the signature of
public static MvcHtmlString Editor(
this HtmlHelper html,
string expression,
Object additionalViewData
)
How exactly are you supposed to use additionalViewData? The MSDN documentation is not clear at all.
My first thoughts were along the lines of:
@Html.Editor("quijibo", new { quijibo = "homer simpson" })
However this doesn’t work so I’m at a loss at this point.
Edit: Revised question to be How do you directly load a value from Object additionalViewData in Html.Editor? I want a value I place in additionalViewData to be used as the data value of that editor.
The answer to my question is that it is impossible with the built in classes.
The code structure of them overwrites anything you would stuff into
htmlAttributes: new { value = "x" }.I found this to be very inconvenient. I created methods to parallel the internal workings of the MVC methods that are all similar to:
The major difference is that I ordered calls such that
tagBuilder.MergeAttributesis last so that you can always override ANYTHING using theobject htmlAttributes. The MVC source code goes the opposite way and applies the attributes first, thereby making their solution substantially less flexible.