javascript - Is it possible to pass a list/array of arguments to a JS function from C#? -


for instance possible pass following parameters arguments js function code-behind?:

ddllines.attributes.add("onchange", "setpanel("         + " '" + ddladd.clientid + "', "         + " '" + nckptitle.clientid + "', "         + " '" + manckentry.clientid + "', "         + " '" + ncklabel.clientid + "', "         + " '" + txtrefno.clientid + "', "         + " '" + tcee.pval + "', "         + " '" + tcee.ptxt + "', "         + " '" + ddllines.clientid + "' "         + ");" 

at time js function argument list follows:

function setpanel(ddlclientid, lblclientid, lblmanclientid,      lblrefno, altrefno, altvalparm, alttxtparm, ddllinesclientid){    ... } 

i able dynamically send indeterminate list of parameters arguments js function code behind.

i have researched .apply() function, have not been able use successfully.

you need add [] ,it means array in js

ddllines.attributes.add("onchange", "setpanel("         + " ['" + ddladd.clientid + "', "         + " '" + nckptitle.clientid + "', "         + " '" + manckentry.clientid + "', "         + " '" + ncklabel.clientid + "', "         + " '" + txtrefno.clientid + "', "         + " '" + tcee.pval + "', "         + " '" + tcee.ptxt + "', "         + " '" + ddllines.clientid + "'] )"         ); 

but suggest can use json here,such as

ddllines.attributes.add("onchange", "setpanel("             + " {'aaaid':'" + ddladd.clientid + "', "             //...             + " 'zzzid':'" + ddllines.clientid + "'} )"             ); 

Comments