Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DropDownListFor binding
Message
 
 
À
15/01/2013 12:21:59
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Versions des environnements
Environment:
C# 5.0
Divers
Thread ID:
01562476
Message ID:
01562684
Vues:
31
>>>>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.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform