I have this Model:
public class Package
{
public string CustomerName { get; set; }
public List<Product> Products { get; set; }
}
public class Product
{
public int Quantity { get; set; }
public string Name { get; set; }
}
When I add the Create’s view, the code is:
<fieldset>
<legend>Fields</legend>
<div class="editor-label">
<%: Html.LabelFor(model => model.CustomerName) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.CustomerName) %>
<%: Html.ValidationMessageFor(model => model.CustomerName) %>
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
How manage the Products list?
Can I get a button or something to create a new product and add it to the Products list?
Thank you
for creating buttn you can also do this use HTML.ActionLink() or Ajax.ActionLink() defined as a button like:
it’ll create a button on your page, and here you can see different attributes (so just check them out you’ll find it useful) … and from both of this which to use is more depends upon your desired action …
and in your controller:
here is the example: modal popup, declared as a partial view of page
[partial view using Ajax.ActionLink()]
your partial view action: