NOTE: The magic will also not happen if you just write <input type=”text”/> on the page. It only happens if you use Html.TextBox.
The solution: I am still new to MVC and still trying to wrap my head around the “right way” to do things. Reflector showed that the HtmlHelpers all looked at the ModelState in the ViewData before rendering their HTML. They looked for their value by key (key being the control/tag name), and, if present, used that as the control/tag’s value. Bing! Maybe I should do the same thing. So just before I go to town with TagBuilder to assemble my controls/tags, I look in the ViewData’s ModelState for my value. If it is there, it must have been posted there by me (my control).
48 UrlHelper urlHelper = new UrlHelper(helper.ViewContext.RequestContext);
49 string textValue = null;
50 ModelState state;
52 if (helper.ViewData.ModelState.TryGetValue(textFieldName, out state))
54 textValue = state.Value.AttemptedValue;
40 <%= Html.MySelector(“selectedIDs”, “selectedNames”, “State”)%>