When I render DevExpress MVC controls for nested fields, using a custom FormBuilder
class of my own, I'm using the naming convention of ModelName.FieldName
. This fixes binding issues I was having, but I now need client-side access to the JavaScript objects that are created for the control.
In the past, I would find an object called FieldName
. For nested fields, what is the naming pattern for the JavaScript object name (since ModelName.FieldName
would not be a suitable JavaScript object name), and is there perhaps an alternative way to access the object by passing in the full field name as a parameter to some JavaScript method (something like AllControls.GetControl('ModelName.FieldName')
)?
Here is a sample of my code:
var textBoxSettings = new TextBoxSettings
{
Name = "ModelName.FieldName",
};
writer.Write(devExpress.TextBox(textBoxSettings).GetHtml());
UPDATE:
It appears that DevExpress does indeed render objects with the name ModelName.FieldName
. I'm not sure how to access those objects in JavaScript - is there some kind of escape sequence to treat the entire phrase as a single variable name?
DevExpress does actually create the JavaScript object with a variable name in the form
ModelName.FieldName
.To access that object in JavaScript, you can use the format: