我创建了两个对象,并希望将它们传递给UpdateJson.aspx.cs
。
如何在UpdateJson.aspx
页面上检索这两个对象?
我在UpdateJson.aspx
页面上收到错误。
function AddJSon() {
var jsonOrderData = [];
jsonOrderData.push({
SalesOrderId: $("#<%=hdnOrderId.ClientID%>").val(),
CustomerId: $("#<%=hdnCustomerId.ClientID%>").val(),
SalesOrderDate: $("#cpContent_txtSalesOrderDate").val(),
DeliveryDate: $("#cpContent_txtDeliveryDate").val(),
GeneralDocument: $("#<%=hdnGeneratedDocumentName.ClientID%>").val(),
OriginalGeneralDocument: $("#<%=hdnGeneratedDocumentName.ClientID%>").val(),
TermsId: $("#<%=hdnTerm.ClientID%>").val(),
CustomerPurchaseOrder: $("#cpContent_txtCusPurchaseOrder").val(),
TrackingNo: $("#cpContent_txtTrackingNo").val(),
SubTotal: $('#<%=lblSubTotal.ClientID%>').val(),
Tax: $("#cpContent_txtTaxRate").val(),
Shipping: $("#cpContent_txtShippingCharge").val(),
NetTotal: $('#<%=lblNetTotal.ClientID%>').val(),
ShippingAddressID: $("#<%=hdnshipping.ClientID%>").val(),
ShippingCity: $("#cpContent_txtShippingCity").val(),
ShippingCountry: $("#cpContent_txtShippingCountry").val(),
ShippingState: $("#cpContent_txtShippingState").val(),
ShippingStreet: $("#cpContent_txtShippingStreet1").val(),
ShippingStreet2: $("#cpContent_txtShippingStreet2").val(),
ShippingZip: $("#cpContent_txtShippingZip").val(),
SalesOrderNo: $("#cpContent_txtSalesOrderNo").val(),
OrderType: 0,
IsSaveAndSend: $("#<%=hdnIsSaveAndSend.ClientID%>").val(),
EmailIDList: $("#cpContent_txtMultipleEmailId").val(),
ShippingAddress: $("#cpContent_txtShippingAddress").val(),
Comment: $("#cpContent_txtComment").val(),
IsConvert: true,
IsRetailer: false,
})
var jsonProductDetail = [];
$("#<%=grdOrderDetail.ClientID%> tr:has(td)").each(function () {
var ProductCodeCheck = ($(this).find('.ProductCode').val());
if (ProductCodeCheck != '') {
jsonProductDetail.push({
SrNo: $(this).find('.GridTextBox').val(),
ProductId: $(this).find("#hdnEProductId").val(),
ProductName: $(this).find("#txtProduct").val(),
ProductCode: $(this).find('.ProductCode').val(),
VendorId: $(this).find("#hdnEVendorId").val(),
VendorName: $(this).find("#txtVendor").val(),
Qty: $(this).find("#ddlQty").val(),
itemRate: $(this).find("#txtItemRate").val(),
SetUpCharge: $(this).find("#txtSetupCharges").val(),
RunCharge: $(this).find("#txtRunCharge").val(),
Price: $(this).find("#txtPrice").val(),
ImprintMethodId: $(this).find("#hdnEImprintMethodId").val(),
ImprintMethodChargeId: $(this).find("#hdnImprintMethodChargeId").val(),
ImprintLocationId: 0,
ImprintColorId:0,
ImprintMethodName: $(this).find("#hdnImprintMethod").val,
ImprintLocation: $(this).find("#hdnImprintLocation").val,
ImprintColor:"",
IsUrgentOrder:true,
NeedBy:"",
})
}
});
$.ajax({
url: "<%=Host %>Admin/UpdateJson.aspx?type=OrderData",
type: 'POST',
//data: JSON.stringify(jsonArr), { json_1:$.toJSON(data_1), json_2:$.toJSON(data_2) },
data: { json_OrderData: JSON.stringify(jsonOrderData), json_OrderDetail: JSON.stringify(jsonProductDetail) },
contentType: 'application/json; charset=utf-8',
dataType: 'html',
async: false,
success: function (html) {
Isresult = true;
}
})
}
我使用下面的代码来检索UpdateJson.aspx.cs页面上的对象
StreamReader sr = new StreamReader(Request.InputStream);
string strJson = "";
strJson = sr.ReadToEnd();
List<BusinessObject.SampleOrderBO.AttachmentData> returnList = new List<BusinessObject.SampleOrderBO.AttachmentData>();
JavaScriptSerializer serializer = new JavaScriptSerializer();
strJson = "[" + strJson.Replace("[", "").Replace("]", "") + "]";
if (strJson != "[]")
{
returnList = serializer.Deserialize<List<BusinessObject.SampleOrderBO.AttachmentData>>(strJson);
}