First of all , I use MVC 2 with Entity Framework 4.
I Have 2 Entities.
Customers and Emails
There is a Relation 1 to many between Customer and Email. One customer ca have many Email.
My question : In the Customer Creation page form, I have all the info related to the customer. ex:
<%: Html.LabelFor(model = model.FirstName) %>
<%: Html.TextBoxFor(model = model.FirstName) %>
<%: Html.LabelFor(model = model.LastName) %>
<%: Html.TextBoxFor(model = model.LastName) %>
I would like to have an Add Button that will create Email Fields in javascript.
When I Save the customer, that will Associate the Email with the customer.
How can I perform this task??
I Have a couple of ideas, but not sure if it's ok the way I think.
One of them is when I Click the Add Button for email, that will show a Popup with the Email Fields, then when I Click Save Email , that will call the Create Method and save the email in the database. The problem here is, how can I associate this email entry with the customer if the customer is not already saved in the database?.