Side server with WebForms in ASP.NET
Side server with WebForms in ASP.NET
Hi everyone
I have a very large data table (multiple columns and records).
I tried to convert it to server-side processing, however,
everything has been in failed attempts.
I am using Visual Basic with WebForms (not MVC) and WebMethod in ASP.NET, to date
I have not been able to get it to work, if I use the GET method it marks an error because the string
it is very long, and with the POST method it failed to send the parameters.
Does anyone have an idea how to achieve it?
Thank you
<table id="tblCustomers" >
<thead>
<tr>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
<th>Col4</th>
<th>Col5</th>
<th>Col6</th>
<th>Col7</th>
<th>Col8</th>
<th>Col9</th>
<th>Col10</th>
<th>Col11</th>
<th>Col12</th>
<th>Col13</th>
<th>Col14</th>
<th>Col15</th>
<th>Col16</th>
<th>Col17</th>
<th>Col18</th>
<th>Col19</th>
<th>Col20</th>
<th>Col21</th>
<th>Col22</th>
<th>Col23</th>
<th>Col24</th>
<th>Col25</th>
<th>Col26</th>
<th>Col27</th>
<th>Col28</th>
<th>Col29</th>
<th>Col30</th>
<th>Col31</th>
<th>Col32</th>
<th>Col33</th>
<th>Col34</th>
<th>Col35</th>
<th>Col36</th>
<th>Col37</th>
<th>Col38</th>
</tr>
</thead>
<tbody></tbody>
</table>
$(document).ready(function () {
var table = $('#tblCustomers').prepend($("").append($('#tblCustomers').find("tr:first"))).DataTable({
"serverSide": true,
"Processing": true,
"ajax":
{
"type": "POST",
"method": "POST",
"dataType": 'json',
"contentType": "application/json",
"url": 'Example.aspx/GetData',
"data": function (d) {
return JSON.stringify(d);
},
"dataSrc": "d.data",
},
"columns": [
{ "data": "Col1" },
{ "data": "Col2" },
{ "data": "Col3" },
{ "data": "Col4" },
{ "data": "Col5" },
{ "data": "Col6" },
{ "data": "Col7" },
{ "data": "Col8" },
{ "data": "Col9" },
{ "data": "Col10" },
{ "data": "Col11" },
{ "data": "Col12" },
{ "data": "Col13" },
{ "data": "Col14" },
{ "data": "Col15" },
{ "data": "Col16" },
{ "data": "Col17" },
{ "data": "Col18" },
{ "data": "Col19" },
{ "data": "Col20" },
{ "data": "Col21" },
{ "data": "Col22" },
{ "data": "Col23" },
{ "data": "Col24" },
{ "data": "Col25" },
{ "data": "Col26" },
{ "data": "Col27" },
{ "data": "Col28" },
{ "data": "Col29" },
{ "data": "Col30" },
{ "data": "Col31" },
{ "data": "Col32" },
{ "data": "Col33" },
{ "data": "Col34" },
{ "data": "Col35" },
{ "data": "Col36" },
{ "data": "Col37" },
{ "data": "Col38" }
],
rowId: 'Col1',
responsive: false,
sPaginationType: "full_numbers",
stateSave: false,
"bDestroy": true,
destroy: true,
select: true,
"order": [[0, "desc"]],
orderCellsTop: false,
fixedHeader: true,
pageLength: 25,
"scrollY": 350,
"scrollX": true,
}); //End function datatable
});
Answers
When using POST use the browser's network inspector tool to view the XHR request. You should see the a section called Form Data with the sent parameters. Just like this example. Your server script will need to be configured to process POST requests instead of GET.
Kevin