>>>>I guess for now I'll go ahead, grab Id's from ViewSource and use them in my code and bind manually.
>>>
>>>Thinking about it - doesn't the name of each control get set by default to reflect the relevant property in the viewmodel. If that's the case the maybe writing jscript to populate from the return values would be simple enough ?
>>
>>Can you clarify?
>>
>>Also, my Client class has few Complex Types, so the Id sometimes is not the name of the property, e.g. my Client class:
>
>Forget Id. The 'Name' attribute of the control reflects the model property. e:g Name= Client.Contact1.phoneInfo.Phone
>
Right. In jquery should I still use id when I bind the model property to control or name of the control?
Also, do you see a way to write a generic routine to map model properties to their controls?
In other words, my task right now:
I have
$.getJSON(url, id, function (data) {
});
RunModalDialog("Edit Client: " + ClientName);
in javascript
and this in the Details action:
public ActionResult Details(int id)
{
var client = Db.GetClientById(id);
return Json(client, JsonRequestBehavior.AllowGet);
}
also note that for now I'm just returning client as JSON, but I am using ClientViewModel in the view.
If it's not broken, fix it until it is.
My Blog