Reputation: 417
I'm kind new in the MVC world and I am stucked on a situation that seems pretty simple.
I have a model named Company, and each Company can have many Contacts (name and phone).
What I want is to display a first set of fields for a Contact and a Add Another link that adds the html fields for a new contact.
How can I do that? I know that I can create the fields using JS but how can I send this to my controller? Is there a MVC-way yo do that?
I'm using EF as well
Upvotes: 0
Views: 75
Reputation: 3374
you can use ajax calls to talk to your controllers through js.
jQuery
var controlName = '/YourControlerName/';
$.getJSON(controlName + 'GetTelss',
function (data)`
{
/// update your ui
});
});
MVC
public ActionResult GetTels()
{
return Json(yourDAta,JsonRequestBehavior.AllowGet);
}
Upvotes: 1