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

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

java - UML - How would you draw a try catch in a sequence diagram? -

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