javascript - Passing a string value from c# file to js file -


i trying pass string value c# file js file.

if try pass int value, can pass it, unable pass string value.

string value = "abc";  int a=5;  tablecell.attributes.add("onclick", "f1("+value +")"); //nothing happens  tablecell.attributes.add("onclick", "f1("+a +")"); //works 

js file

function f1(value) {     alert(value); } 

pass string value in quotes ''

use

tablecell.attributes.add("onclick", "f1('"+value +"')");                                          ^          ^ 

otherwise treated variable. must getting error in browser console.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -