Click here to Skip to main content
15,667,466 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How do I pass list of objects and string back to server?

Please look at the my code. It tried to debug, it never get back to server. it throws error :
Possibly unhandled rejection: obj' is not supported for deserialization of an array

What I have tried:

<tr ng-repeat="r in Students">
<td>{{::r.Name}}</td>
<td>{{::r.Class}}</td>
</tr>
<pre><asp:TextBox ID="fnBox" runat="server" class="form-control" placeholder="file name" ng-model="xlfileName"></asp:TextBox>

<input type="button" value="SendFile" ng-click="SendFile(Students)" />

angularJs:

$scope.SendFile = function (Data) {

      var dataArray = [];
dataArray.push(Data);
dataArray.push($scope.xlfileName);

        debugger;
        $http({
            method: "POST",
            url: "StudentList.aspx/GetStudent",
            data: { dataList:dataArray},
            contentType: "application/json",
            dataType: "json"
        }).then(function (response) {

            debugger;
            console.log(response);
        });

    }


public static string GetStudent(List<DemoList> dataList)
       {



       }


public class DemoList
   {
       public List<Student> students { get; set; }
       public string Fn { get; set; }
   }
Posted
Updated 1-Aug-17 20:21pm
v3

1 solution

since my requirement needed to pass the fileName also along with list of students now it created another problem.
 
Share this answer
 
v2
Comments
Karthik_Mahalingam 2-Aug-17 1:32am    
Use Improve question to add more info to the question.
dont use solution widget to post comments
Graeme_Grant 16-Sep-17 8:06am    
Please don't answer your own question with a solution and then accept it as a valid solution. This is see as REP farming and can get you banned if continued. Update your question instead.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900