Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DropDownListFor binding
Message
From
15/01/2013 13:10:12
 
General information
Forum:
ASP.NET
Category:
MVC
Environment versions
Environment:
C# 5.0
Miscellaneous
Thread ID:
01562476
Message ID:
01562713
Views:
25
>>>>>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) {
>                  //  setFormControls(data.Id, data.Role, data.Location, data.JobType, data.Description);
>                });
>               //location.replace(url);
>               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.

What does the Json data look like ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform