c# - Access list of data in the Master Page code behind to front end of the same master page using Javascript -


i'm loading of data list called "transactionnames" in code behind of master page (testmaster.master). need pass list of data front-end of master page(testmaster.master) using java script. tried above,

enter image description here

if have list in code behind declared outside method:

public list<string> transactionnames = new list<string>(); 

then need create array in javascript:

<script type="text/javascript">     var transactionnames = ["<%= string.join("\",\"", transactionnames) %>"];      //or      var transactionnames = <%= "['" + string.join("','", transactionnames) + "']" %>;      (var = 0; < transactionnames.length; i++) {         alert(transactionnames[i]);     } </script> 

or becomes easier when use newtonsoft.json serialize objects:

var transactionnames = <%= newtonsoft.json.jsonconvert.serializeobject(transactionnames) %>; 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -