No you cannot access the pieces a server control is composed of manually. There is a standard way to set and get the values of simple sever controls(here simple menas they are not composed by several items, but display or edit a single value) that are composed
of several html parts:
function MvcControlsToolkit_<ControlType>_Set(sorg, value, format, valueType)
function MvcControlsToolkit_<ControlType>_Get(sorg, valueType)
where <ControType> is the the type of control. For the controls we have at moment in the Mvc Controls Toolkit<ControType> may have the following values:
- DateTimeInput for the date time control
- TypedTextBox for the TypedTextBox
- TypedEditDisplay for the EditDisplay
thus in the case of DateTime we have:
function MvcControlsToolkit_DateTimeInput_Set(sorg, value, format, valueType)
Now the parameters:
- sorg is the DOM element working as representative of the whole control. I explain in a short time how to get it.
In the case of the date input it must be: MvcControlsToolkit_DataType_DateTime. You can use the name directly since it is defined in the js file.
- format is the the display format to be used. It is relevant for TypedTextBox and TypedEditDisplay, while in the case of the date input you can pass any value, since formatting is standard. If you are interested about possible value for the format
string see here: https://github.com/jquery/jquery-global (however it is not required in the case of dates).
the sorg element from its id with document,getElementById(id):
- DateTimeInput: Html.PrefixedId(m => m.MyDateTime) + "_Hidden" or Html.StandardIdFor(m => m.MyDateTime) + "_Hidden" or Html.PrefixedId("MyDateTime") + "_Hidden";
- TypedTextBox: Html.PrefixedId(m => m.MyProperty) + "_hidden" or Html.StandardIdFor(m => m.MyProperty) + "_hidden" or Html.PrefixedId("MyProperty") + "_hidden";
- TypedEditDisplay: Html.PrefixedId(m => m.MyProperty) or Html.StandardIdFor(m => m.MyProperty) or Html.PrefixedId("MyProperty") ;