The problem you encountered is specific of the DateTime-DateTimeFor. It ALWAYS MUST be inserted in a ViewModel, since it "looks" for constraints involving other DateTiMeFor belonging to the same ViewModel. If you use any other Mvc Controls Toolkit
control susch as the TypedTextBox you will be able to use it as a normal TextBoxFor.
The peculiarity of the DataTimeFor is due to its capability of buidling networks of constrainst (< <= >= etc.) with other DateTimeFor .
Now, You are right you should never use DateTime instead of DateTimeFor....but the same is true for TextBox...actually also TextBox don't let you choose the esact name of the control, since it adds a "prefix" to all names. The prefix is set in the
ViewDataDictionary. If you call the TextBox from the Main View the prefix is "" so you may decide the full bame...but if you call it from within a PartialView in general the prefix is not empty, so if you specify a name: "myname" in the
TextBox helper your input will have the name: "prefix.myname"
TextBox type helpers were introduced BEFORE TextBoxFor helpers...that are more evolute, but if you DONT use the Mvc Controls Toolkit they are still usefull when the you want the TextBox to be bound to a model that is different from the main View VieModel. This
happens, for instance, when the ViewModel that receives the post of your form submit is different from the ViewModel used to create the View.
If you do use the Mvc Controls Toolkit you may use howw many viewmodels you want in your View. In fact you may create other Html helper based on other ViewModels. This can be done with the
So in your case you may create the ViewmModel to use for your Ajax call and you may use the helper created with CrossHelper to render all controls involved in the call. The advantage of this Model/based approach is that you may specify validation rules for
However, if you want that each call to ajax gives different names to all controls you cant use this simple approach and you must use client blocks that takes care of creating new names dynamically.