G
Guest
Hello,
After I posted yesterday "using C# class in jscript", I have a new problem:
I have a C# class - DBResult - that contains (and other variables) a string
array (and other variables), that contains data from a database query which
is done in C# in codebehind. I create a jscript - script that is injected
into the aspx-page. I need this to fill an activeX-control with data.
I assign the string-array (and - for testing - a single stringArray-Entry)
to variables in jscript. This works. But when I want to reassign these
jscript variables to other jscript variables, these newly assigned variables
only return "undefined", when I output them via "alert". I have to process
the data in jscript, so I can make it appear in my activeX control (a
2D-graph visualisation)
In Codebehind, I write the following (for testing):
// initialize DBResult for testing:
string[] strings = { "one", "two" };
DBResult res = new DBResult(strings);
// The array is publicly available as a Property named Strings
// create JScript-Code:
string script = "<script language=jscript>";
script += "function loadDB() {";
script += "testStrings = " + "\"" + res.Strings + "\"" + ";"; // this works!
script += "alert(testStrings)"; // returns "System.String[]"
script += "testString = " + "\"" res.Strings[0] + "\"" + ";"; // this works!
script += "alert(testString)"; // returns "one"
script += "s1 = testStrings[0];"; // asignment from jscript variable to
jscript variable
script += "alert(s1)"; // returns undefined, BUT I DON'T KNOW WHY
script += "return false;"; // verhindert Postback
script += "}";
script += "</script>";
RegisterClientScriptBlock("Block1", script);
this.button1.Attributes.Add("OnClick", "return loadDB();");
I hope I made clear the problem, so I hope somebody can help.
Thanks in advance.
RFS666
After I posted yesterday "using C# class in jscript", I have a new problem:
I have a C# class - DBResult - that contains (and other variables) a string
array (and other variables), that contains data from a database query which
is done in C# in codebehind. I create a jscript - script that is injected
into the aspx-page. I need this to fill an activeX-control with data.
I assign the string-array (and - for testing - a single stringArray-Entry)
to variables in jscript. This works. But when I want to reassign these
jscript variables to other jscript variables, these newly assigned variables
only return "undefined", when I output them via "alert". I have to process
the data in jscript, so I can make it appear in my activeX control (a
2D-graph visualisation)
In Codebehind, I write the following (for testing):
// initialize DBResult for testing:
string[] strings = { "one", "two" };
DBResult res = new DBResult(strings);
// The array is publicly available as a Property named Strings
// create JScript-Code:
string script = "<script language=jscript>";
script += "function loadDB() {";
script += "testStrings = " + "\"" + res.Strings + "\"" + ";"; // this works!
script += "alert(testStrings)"; // returns "System.String[]"
script += "testString = " + "\"" res.Strings[0] + "\"" + ";"; // this works!
script += "alert(testString)"; // returns "one"
script += "s1 = testStrings[0];"; // asignment from jscript variable to
jscript variable
script += "alert(s1)"; // returns undefined, BUT I DON'T KNOW WHY
script += "return false;"; // verhindert Postback
script += "}";
script += "</script>";
RegisterClientScriptBlock("Block1", script);
this.button1.Attributes.Add("OnClick", "return loadDB();");
I hope I made clear the problem, so I hope somebody can help.
Thanks in advance.
RFS666