Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DropDownListFor binding
Message
 
 
General information
Forum:
ASP.NET
Category:
MVC
Environment versions
Environment:
C# 5.0
Miscellaneous
Thread ID:
01562476
Message ID:
01562715
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 ?

I'm testing this using Opera browser and looks like the Details method is not being hit at all, I don't know why. I put a breakpoint in the Details method of the controller, but when I click on the Edit button now it just opens the empty form, the same way as Add.

I am going to test using IE now that allows to trace JavaScript code also.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform