前台:
<asp:HiddenField ID="HfContacts" runat="server" Value="" />
var item = { name: _name, tel: _tel };
contacts.push(item);
$("#HfContacts").val(JSON.stringify(contacts));
后台:
[DataContract]
class Contact
{
[DataMember]
public string name { get; set; }
[DataMember]
public string tel { get; set; }
}
//保存联系方式
Dictionary<string, string> wayContact = new Dictionary<string, string>();
List<Contact> contacts = BaiKeTool.SerializationHelper.JsonDeserialize<List<Contact>>(HfContacts.Value);
foreach (var item in contacts)
{
wayContact.Add(item.name, item.tel);
}