By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,493 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,493 IT Pros & Developers. It's quick & easy.

using C# class in jscript

P: n/a
Hello,

I have the following problem:
I have a web project where I display an activeX control that displays
2D-graphs on an aspx-page. I use jscript to access and modify the properties
of the activeX-2D-control. In
codebehind, I use C# for the application logic (eg. the database access).
The query to the database retuns me an object of a C# class (called
DBResultSet) that contains all the data from the query. This data has then to
be visualized on the 2d-graph activeX control on the .aspx-page
Here comes my question now:
How can I access the properties & methods of the class DBResultSet to assign
them to arrays and objects in jscript.
I know that the activeX control and jscript work on the clientside and the
application logic (written in C#) runs on the server. But the activeX control
can only be accessed on the clientside and I need the data from the database
to be displayed in the activeX-control.

I hope, somebody can help

thanks in advance

RFS666
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Two thing that comes to mind.

1) XmlHttp. Why not use Ajax to request the data in an Xml Format, which
your JScript can read and and set your 2d-graph appropriately.

2) Alternately, your C# code can write the JavaScript on page load and use
the Class DBResultSet while doing so

HTH

-G

"RFS666" <RF****@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.com...
Hello,

I have the following problem:
I have a web project where I display an activeX control that displays
2D-graphs on an aspx-page. I use jscript to access and modify the
properties
of the activeX-2D-control. In
codebehind, I use C# for the application logic (eg. the database access).
The query to the database retuns me an object of a C# class (called
DBResultSet) that contains all the data from the query. This data has then
to
be visualized on the 2d-graph activeX control on the .aspx-page
Here comes my question now:
How can I access the properties & methods of the class DBResultSet to
assign
them to arrays and objects in jscript.
I know that the activeX control and jscript work on the clientside and the
application logic (written in C#) runs on the server. But the activeX
control
can only be accessed on the clientside and I need the data from the
database
to be displayed in the activeX-control.

I hope, somebody can help

thanks in advance

RFS666

Nov 19 '05 #2

P: n/a
Wow, thanks for the quick answer.

I decided to try alternative 2.
I create a string that contains the whole script code, beginning with
<script=jscript> and ending with </script>. Then I use the
registerClientScriptBlock method to inject the string containing the
scriptcode into the aspx-page.
But I don't know how to use the DBResult class in this script block.
The DBResult class contains a string array and an object array, these two
things have to be assigned to jscript string arrays and object arrays. My
problem is, I don't know how to make the cross-language assignment in the
scriptblock.
I tried like this:
string script = "<script language=jscript>";
script += "function useResult() {";
script += "var result : DBResult =
nameOfTheProtectedVariableInCodeBehindOfTypDBResul t"; // Error in this line
script += "}";
script +="</script>";
RegisterClientScriptBlock("scriptBlock", script);

But this doesn't work.
Do I have to import something or so?

Thanks.

RFS666

"Grant Merwitz" wrote:
Two thing that comes to mind.

1) XmlHttp. Why not use Ajax to request the data in an Xml Format, which
your JScript can read and and set your 2d-graph appropriately.

2) Alternately, your C# code can write the JavaScript on page load and use
the Class DBResultSet while doing so

HTH

-G

"RFS666" <RF****@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.com...
Hello,

I have the following problem:
I have a web project where I display an activeX control that displays
2D-graphs on an aspx-page. I use jscript to access and modify the
properties
of the activeX-2D-control. In
codebehind, I use C# for the application logic (eg. the database access).
The query to the database retuns me an object of a C# class (called
DBResultSet) that contains all the data from the query. This data has then
to
be visualized on the 2d-graph activeX control on the .aspx-page
Here comes my question now:
How can I access the properties & methods of the class DBResultSet to
assign
them to arrays and objects in jscript.
I know that the activeX control and jscript work on the clientside and the
application logic (written in C#) runs on the server. But the activeX
control
can only be accessed on the clientside and I need the data from the
database
to be displayed in the activeX-control.

I hope, somebody can help

thanks in advance

RFS666


Nov 19 '05 #3

P: n/a
You need to come out of your inverted comma's

Lets make a basic example.

Code Behind

private void Page_Load(object Sender, EventArgs e)
{
string str = "HELLO";
string MyScript = "";
MyScript = "<script language=jscript>";
MyScript += "alert(" + str + ");"; //Here i am coming out of the string
into the code
MyScript +="</script>";
RegisterClientScriptBlock("scriptBlock", MyScript);
}

the effect.
A popup box that says hello :)

So when your setting your script, remember to come out of the inverted
comma;s to start using your c# variables or methids.

Hope thats clear enough
"RFS666" <RF****@discussions.microsoft.com> wrote in message
news:ED**********************************@microsof t.com...
Wow, thanks for the quick answer.

I decided to try alternative 2.
I create a string that contains the whole script code, beginning with
<script=jscript> and ending with </script>. Then I use the
registerClientScriptBlock method to inject the string containing the
scriptcode into the aspx-page.
But I don't know how to use the DBResult class in this script block.
The DBResult class contains a string array and an object array, these two
things have to be assigned to jscript string arrays and object arrays. My
problem is, I don't know how to make the cross-language assignment in the
scriptblock.
I tried like this:
string script = "<script language=jscript>";
script += "function useResult() {";
script += "var result : DBResult =
nameOfTheProtectedVariableInCodeBehindOfTypDBResul t"; // Error in this
line
script += "}";
script +="</script>";
RegisterClientScriptBlock("scriptBlock", script);

But this doesn't work.
Do I have to import something or so?

Thanks.

RFS666

"Grant Merwitz" wrote:
Two thing that comes to mind.

1) XmlHttp. Why not use Ajax to request the data in an Xml Format, which
your JScript can read and and set your 2d-graph appropriately.

2) Alternately, your C# code can write the JavaScript on page load and
use
the Class DBResultSet while doing so

HTH

-G

"RFS666" <RF****@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.com...
> Hello,
>
> I have the following problem:
> I have a web project where I display an activeX control that displays
> 2D-graphs on an aspx-page. I use jscript to access and modify the
> properties
> of the activeX-2D-control. In
> codebehind, I use C# for the application logic (eg. the database
> access).
> The query to the database retuns me an object of a C# class (called
> DBResultSet) that contains all the data from the query. This data has
> then
> to
> be visualized on the 2d-graph activeX control on the .aspx-page
> Here comes my question now:
> How can I access the properties & methods of the class DBResultSet to
> assign
> them to arrays and objects in jscript.
> I know that the activeX control and jscript work on the clientside and
> the
> application logic (written in C#) runs on the server. But the activeX
> control
> can only be accessed on the clientside and I need the data from the
> database
> to be displayed in the activeX-control.
>
> I hope, somebody can help
>
> thanks in advance
>
> RFS666


Nov 19 '05 #4

P: n/a
Hello Grant,
thanks for you quick and patient help,

you helped me really a lot!

RFS666
Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.