連絡先情報があり、ユーザーがいくつかの連絡先を追加して保存したい.つまり、連絡先ごとに連絡先情報をサーバーに送信したくないので、クライアントに保存し、[保存]ボタンをクリックした後、すべてどうすれば保存できますか? リストに追加して保存する方法は? 私のモデルクラスは次のとおりです。
public System.Guid ContactId { get; set; }
public string Tel { get; set; }
public string Fax { get; set; }
public string Mobile { get; set; }
とビューで:
<% using (Html.BeginForm()) { %>
<%: Html.ValidationSummary(true) %>
<div class="editor-label">
<%: Html.LabelFor(model => model.Tel) %>
</div>
<div class="editor-field">
<%: Html.EditorFor(model => model.Tel) %>
<%: Html.ValidationMessageFor(model => model.Tel) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Fax) %>
</div>
<div class="editor-field">
<%: Html.EditorFor(model => model.Fax) %>
<%: Html.ValidationMessageFor(model => model.Fax) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Mobile) %>
</div>
<div class="editor-field">
<%: Html.EditorFor(model => model.Mobile) %>
<%: Html.ValidationMessageFor(model => model.Mobile) %>
</div>
<% using (Html.BeginForm()) { %>
<%: Html.ValidationSummary(true) %>
<div class="editor-label">
<%: Html.LabelFor(model => model.Tel) %>
</div>
<div class="editor-field">
<%: Html.EditorFor(model => model.Tel) %>
<%: Html.ValidationMessageFor(model => model.Tel) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Fax) %>
</div>
<div class="editor-field">
<%: Html.EditorFor(model => model.Fax) %>
<%: Html.ValidationMessageFor(model => model.Fax) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Mobile) %>
</div>
<div class="editor-field">
<%: Html.EditorFor(model => model.Mobile) %>
<%: Html.ValidationMessageFor(model => model.Mobile) %>
</div>
<div class="demo">
<button >
<span class="ui-button-text">Add to list</span></button>
</div>
<% List<Contact> list = (List<Contact>)ViewBag.ListContacts; %>
<fieldset>
<legend>Contacts</legend>
<table>
<tr>
<th>
Tel
</th>
<th>
Fax
</th>
<th>
Mobile
</th>
<th>
</th>
</tr>
<% foreach (var itm in list)
{ %>
<tr>
<td>
<%: Html.DisplayFor(f => itm.Tel) %>
</td>
<td>
<%: Html.DisplayFor(m => itm.Fax)%>
</td>
<td>
<%: Html.DisplayFor(m => itm.Mobile)%>
</td>
<td>
<%: Html.ActionLink("Delete","Delete",new {id= itm.ContactId}) %>
</td>
</tr>
<% } %>
</table>
</fieldset>
<% } %>
<% List<Contact> list = (List<Contact>)ViewBag.ListContacts; %>
<fieldset>
<legend>Contacts</legend>
<table>
<tr>
<th>
Tel
</th>
<th>
Fax
</th>
<th>
Mobile
</th>
<th>
</th>
</tr>
<% foreach (var itm in list)
{ %>
<tr>
<td>
<%: Html.DisplayFor(f => itm.Tel) %>
</td>
<td>
<%: Html.DisplayFor(m => itm.Fax)%>
</td>
<td>
<%: Html.DisplayFor(m => itm.Mobile)%>
</td>
<td>
<%: Html.ActionLink("Delete","Delete",new {id= itm.ContactId}) %>
</td>
</tr>
<% } %>
</table>
</fieldset>
<div class="demo">
<button >
<span class="ui-button-text">Save</span></button>
</div>
<% } %>