Brother Fall you have found the answer when you read this article.
I have wasted my afternoon off on the point of solving this problem. So you should give me a praise!!!
No nonsense. On the code:
Entity (Model)
[Serializable] Public Partial classDictionarys {#regionModel Public stringID {Set; Get; } /// <summary> /// /// </summary> Public stringParentID {Set; Get; } /// <summary> /// /// </summary> Public stringText {Set; Get; } /// <summary> /// /// </summary> Public stringValue {Set; Get; } /// <summary> /// /// </summary> Public stringOrderindex {Set; Get; } /// <summary> /// /// </summary> Public BOOLIsSystem {Set; Get; } /// <summary> /// /// </summary> Public BOOLIsdel {Set; Get; } /// <summary> /// /// </summary> PublicDateTime Createtime {Set; Get; } /// <summary> /// /// </summary> PublicDateTime UpdateTime {Set; Get; } #endregionModel }
Controllers the code is as follows:
PublicActionResult Test1 () {List<DapperTemplate.Model.dictionarys> List1 =NewList<dappertemplate.model.dictionarys>(); inti =0; while(I <5) {List1. ADD (NewDapperTemplate.Model.dictionarys () {ID=Guid.NewGuid (). ToString (), Text="Project"+I, Value="Project"+I, ParentID="0000-0000-0000-0000-0000", Orderindex=i.tostring (), IsSystem=false, Isdel=false, Createtime=DateTime.Now, UpdateTime=DateTime.Now,}); I++; } returnView (List1); }
View the code is as follows:
@model List<dappertemplate.model.dictionarys><form action="/dictionarys/test"Method="Post"Id="Form1">@for (inti =0; i < Model.count; i++) { <div>@Html. Raw (string. Format ("<input type= ' text ' name= ' list[{0}].id ' value= ' {1} '/>", i.ToString (), model[i].id)) @Html. Raw (string. Format ("<input type= ' text ' name= ' list[{0}].text ' value= ' {1} '/>", i.ToString (), Model[i].text)) @Html. Raw (string. Format ("<input type= ' text ' name= ' list[{0}].value ' value= ' {1} '/>", i.ToString (), Model[i].value)) </div> } <input type="Submit"Value="Submit"/></form>
<input type= "button" value= "Submit" id= "Button1"/>
Click Submit to monitor Chrome traffic found below:
Found a trick. This is the law of Jiangzi:
list[0]. PropertyName
...
...
...
list[1]. PropertyName
...
...
...
list[2]. PropertyName
...
...
...
Then I use jquery ajax to submit a data comparison of the parameter format.
JavaScript The code is as follows:
varQueryparams = { "List": [ { "id": "0001", "Text": "0001", "Value": "0001", "ParentID": "0001", "Text": "0001", "Orderindex": "0001", "IsSystem": 0, "Isdel": 0, "Createtime": "2018-04-22 20:21:00", "UpdateTime": "2018-04-22 20:21:00" }, { "id": "0002", "Text": "0002", "Value": "0002", "ParentID": "0002", "Text": "0002", "Orderindex": "0002", "IsSystem": 0, "Isdel": 0, "Createtime": "2018-04-22 20:21:00", "UpdateTime": "2018-04-22 20:21:00" }, { "id": "0003", "Text": "0003", "Value": "0003", "ParentID": "0003", "Text": "0003", "Orderindex": "0003", "IsSystem": 0, "Isdel": 0, "Createtime": "2018-04-22 20:21:00", "UpdateTime": "2018-04-22 20:21:00" }, { "id": "0004", "Text": "0004", "Value": "0004", "ParentID": "0004", "Text": "0004", "Orderindex": "0004", "IsSystem": 0, "Isdel": 0, "Createtime": "2018-04-22 20:21:00", "UpdateTime": "2018-04-22 20:21:00" }, { "id": "0005", "Text": "0005", "Value": "0005", "ParentID": "0005", "Text": "0005", "Orderindex": "0005", "IsSystem": 0, "Isdel": 0, "Createtime": "2018-04-22 20:21:00", "UpdateTime": "2018-04-22 20:21:00"}]} $.ajax ({ Type:"POST", DataType:"JSON", URL:"/dictionarys/test", Traditional:false, Data:queryparams, success:function(response) {Alert (json.stringify (response)); } });
Click Submit to monitor chrome traffic found below
Found a trick. This is the law of Jiangzi:
list[0][PropertyName]
...
...
...
list[1][PropertyName]
...
...
...
list[2][PropertyName]
...
...
...
It turns out there's a ghost here.
list[2]. PropertyName and the list[2][PropertyName]
The music is ringing!
We're not the same!
We're not the same!
We're not the same!
fuck jquery serialization Commit This is the ghost, I am also very desperate Ah!!!
So I'm a little bit of a sissy. Horizontal Slot Horizontal Slot Horizontal Slot There's really a solution.
JavaScript The code is as follows:
functionParseParam (param, key) {varParamstr = ' 'if(paraminstanceofString | | Paraminstanceofnumber | | ParaminstanceofBoolean) {Paramstr+ = ' & ' + key + ' = ' +encodeuricomponent (param)}Else{$.each (param,function(i, p) {if(p = =NULL|| p = =undefined)return true varK = Key = =NULL? I:key + (paraminstanceofArray? ' [' + i + '] ': '. ' +i) Paramstr+ = ' & ' + ParseParam ( This, K)}) } returnPARAMSTR.SUBSTR (1)}
The call is as follows:
$.ajax ({ "POST", "JSON" , "/dictionarys/test", false , parseparam (queryparams), function (response) { alert ( Json.stringify (response)); } );
Well, you can play happily!!!
Hey, West eight!
Technical Exchange QQ Group: 15129679
ASP. NET MVC submit list to background no data received