passing generic list from jquery to c# code-behind -


i have simple webmethod , filtering reports in code-behind :-

    [webmethod(enablesession = true)]     public static list<report> fetchreports(string reportname)     {         list<report> fetchedreports = datamodel.populatelinks().where(r => r.name.tolower().contains(reportname.tolower())).tolist();         return fetchedreports;     } 

now returned jquery function:-

        $("#reports-textsearch").keyup(function () {         var textlength = $(this).val().length;         if (textlength > 2) {             var args = {                 reportname: document.getelementbyid('reports-textsearch').value             };             $.ajax({                 type: "post",                 contenttype: "application/json; charset=utf-8",                 url: "dashboard.aspx/fetchreports",                 data: json.stringify(args),                 datatype: "json",                 success: function(r) {                     var reports = r.data;                     $.each(reports, function (index, report) {                         $("#div1").append("<strong>" + report.name + "</strong>" + "<br/>" +                         "id: " + report.id + "<br />" +                         "displayname: " + report.displayname + "<br />" +                         "url: " + report.url + "<br />" +                         "parentid: " + report.parentid + "<br />" +                         "reportgroupid: " + report.reportgroupid + "<br />" +                         "accesslevel: " + report.accesslevel + "<br />");                         alert(reports);                     });                     //var reports = data.d;                     //__dopostback('div#upmainmenu', reports());                 },                 error: function (data) {                     alert("error");                 }             });          }     }); 

and wish submit page, result of search , populate panel.

at moment code not work, how can change $.each part of code, return actual list, , how can manipulate in c# code-behind desired filtered reports?

thanks , time

hi please follow detail article know how pass parameters frm jquery code behind.

jquery , wcf


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -