473,322 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

using C# class in jscript

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
4 1931
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
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
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
Hello Grant,
thanks for you quick and patient help,

you helped me really a lot!

RFS666
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Christopher Brandsdal | last post by:
I have this string: /sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg, how would I do this? In VBScript I could find the...
6
by: Sergio Otoya | last post by:
Hi all, Is there any way of copying a file using javascript, not using the Filesystemobject (ActiveX). I need this to run in Windows and MACS. Any help would be greatly appreciated. Thanks...
14
by: John Bentley | last post by:
Note this is crossposted to comp.lang.javacript and microsoft.public.dotnet.scripting. After some Googling and FAQing my understanding of these terms is, crudely: Javascript (3 different...
1
by: Peter Petrillo | last post by:
The Access development group here at this company has exported its reports in xml format from Access 2003. I have no influence on how they have created them. I received the following files xm...
2
by: Zach Mortensen | last post by:
I can't seem to get dynamically-compiled JScript code to use C#-defined custom attributes. I have a simple attribute and a class defined in a C# assembly: namespace MyNamespace { public...
1
by: Adrian | last post by:
I appear to be losing ViewState information when calling the __doPostBack function. I am attempting to use the showModalDialog to load a new web page which confirms that a user wishes to save a...
2
by: Jer425 | last post by:
Hello, I'm coding in VB and trying to include a jscript file. This will not work because you can only use one language in asp.net. Is there a way that I can use the jscript without having to...
83
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
9
AnuSumesh
by: AnuSumesh | last post by:
Hi All, I have one dll written in c#. One of its methods return array of dictionary. I want to call and use that method in ASP file. I am using jscript in ASP. my code is a s follows: <%...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.