jQuery结合Json提交数据到Webservice,并接收从Webse(2)


[DataContract]
public class MProductProperty
{
[DataMember(Order = 0, IsRequired = true)]
public int ProductId { set; get; }
[DataMember(Order = 1, IsRequired = true)]
public List<MProperty> PropertyList { set; get; }
}
public class MProperty
{
[DataMember(Order = 0, IsRequired = true)]
public int PropertyId { set; get; }
[DataMember(Order = 1, IsRequired = true)]
public string PropertyType { set; get; }
[DataMember(Order = 2, IsRequired = true)]
public string PropertyValue { set; get; }
}


3、接收并处理Json数据的Web方法:
代码

复制代码 代码如下:


[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public string PostProductPropertyList()
{
string jsonString = HttpContext.Current.Request["propertyList"];
var productProperty = JsonHelper.JsonDeserialize<MProductProperty>(jsonString); // productProperty 成功反序列化成MProductProperty的对象
//返回接收成功标识
return "postsuccess";
}

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdfjwp.html