c# - Push Table to screen -


i have ajax request when branch of jsstree clicked

$("#jstree").bind("select_node.jstree", function(evt, data)  {             var idargument = data.node.text;       $.ajax(       {            type: "post",            url: "webform1.aspx/brancheselectionnee",            data: json.stringify({ id: idargument }),            contenttype: "application/json; charset=utf-8",            success: function(msg)             {                 ;            }        });  }); 

so, call function, make new "page" (because it's static) , call function return system.web.ui.webcontrols.table.

public static string brancheselectionnee(string id) {     var page = (webform1)httpcontext.current.currenthandler;     system.web.ui.webcontrols.table tableau = page.brancheselectionneenonstatique(id);     var stringwriter = new stringwriter();    using (var htmlwriter = new htmltextwriter(stringwriter))    {        tableau.rendercontrol(htmlwriter);    }    string tableaustring=stringwriter.tostring();    return "randomstring"; } 

big problem here: "tableau" updated, want (i see htmlwriter) but.. don't know how put in screen! have in c# code, want in screen, , not here.

i have "tableauarticle" real system.web.ui.webcontrols.table, in asp.net code. tried things, putting "tableauarticle" static,

  tableauarticles = tableau; 

but didn't see changement. think updated table in page don't display

i think main problem pagee isn't refresh or tables wrong.

you ajax request, there no page refresh. string (with html) server method. have manually put string on page. happens in success callback function in code empty. first step try this:

success: function(msg)  {     $('<div class="newtable">').html(msg).appendto('body'); } 

on server-side method brancheselectionnee needs ajaxmethod attribute can called ajax:

[ajax.ajaxmethod()] public static string brancheselectionnee(string id) 

(it should return tableaustring; not "randomstring", right?. , not sure if can use httpcontext.current.currenthandler there, second step if basic ajax stuff works.)

here 1 tutorial gives overview.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -