473,732 Members | 2,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to pass a byte[] from C# to JavaScript

I'm working on a little C# DLL that will let me capture audio from
within Internet Explorer. The idea is that the C# object, once it is
recording, will periodically invoke a JavaScript callback, which will
handle the audio somehow.

The JavaScript callback is a simple function, which I pass to the C#
object during its initialization; I then invoke the JavaScript
callback using

theCB.GetType() .InvokeMember(" ", BindingFlags.In vokeMethod, null,
theCB, new object[]
{arg0, arg1, ...});

My problem is that I can't figure out how to pass a C# byte array to
the JavaScript callback. As long as I pass primitive types,
everything's fine, but when I pass a byte[], the JavaScript code
doesn't seem to recognize the object; "for (i in theArray)" finds no
properties, and any attempt to do things like theArray[0] (indexing)
or theArray.Length results in an Exception.
What is the right way to pass an array from C# to JavaScript?

Thanks,

- Thomas

Jul 2 '07 #1
1 5229
If I remember, you can't do that with JavaScript, because JavaScript only
works with Variant types internally. It's been awhile, but I have returned
System.Arraylis t of objects and was able to walk the ArrayList of objects
and access their accessor properties returned to a JavaScript Variant
object. I have done that and also have returned a dataset back to Javascript
and a assign it to a Variant object and walk the dataset.

However, I was doing this using AjaxPro for .Net, which is free to use.
Jul 2 '07 #2

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

Similar topics

1
1341
by: DC Gringo | last post by:
I am trying to pass an input parater to SQL Server. The parameter is a URL querystring variable. I can't seem to get it to pass a variable, only a literal value... Help! In the following example, the @archiveType parameter accepts the "all" sample value. If I replace "all" with Request.QueryString("archiveType"), it doesn't work. What am I doing wrong?
3
7140
by: tony wong | last post by:
is it possible to detect any double-byte character in the text? thanks. tony
1
2427
by: wbaccay | last post by:
I have a byte of binary data received from a NetworkStream (C# code) that I need to pass to the IWMWriter object in a DLL written in Managed extensions for C++ (since the Windows Media SDK is not usable in C#) whose WriteSample function takes a byte* parameter Do I need to marshal data? I thought I did, so I ran into alot of issues with converting the byte to a string and then, in the MC++ DLL, marshalling that to an IntPtr via...
16
14134
by: Ekim | last post by:
hello, I'm allocating a byte-Array in C# with byte byteArray = new byte; Now I want to pass this byte-Array to a managed C++-function by reference, so that I'm able to change the content of the byteArray and afterwards see the changes in C#. (if you wanna know more details: the goal is to write the content of an existing char-array in c++ precisely into the passed byteArray, so that after the function has proceded the content of the...
2
7548
by: Steve Bottoms | last post by:
Is there any way to pass a login name/password when calling System.Web.Mail.SMTPMail? Can't find anything in the docs or KB... If not, any suggestions to get this functionality short of building something straight from sockets? Third party component isn't an option... :) Thanks! Jack
0
2331
by: sebascomeau | last post by:
Hi everyone, Hello my name is Sebastien and I need some help. He have one week past and I search to do one thing but I can't. If someone help me, I'll be so happy :). My problem is I want to upload a file(image), convert this image in an array of byte. Take this array and pass it to a web service. The web service take this array of byte and resize the image and return a new array of byte. This new array can be save on the harddrive. I...
1
8637
by: kmercer46 | last post by:
I have the byte array generated and I also have the web service generated what i need to know is how to pass a byte array to the web service itself any help would be appreciated.
2
7424
ronverdonk
by: ronverdonk | last post by:
I hope someone can show me the right direction for solving my problem. I have program where a user can enter text in a <textarea>. I want to give that user the possibility to have a pre-look at how his entered data looks at an html screen. I want to show him that in a separate window. So I use the JavaScript window.open function, passing it the text-processing program and the text that the user has entered so far. For this I use the...
4
2118
RedSon
by: RedSon | last post by:
I'm doing a bit of bluetooth programming and I am writing some middleware to make developing applications easier. The BT driver is implemented as a simple serial driver so its like OpenFile and WriteFile and ReadFile. So I get a notification from the module that there is a phone that wishes to make a hands free profile connection to my device. It also give me a big byte array with some information about the phone that is requesting to connect....
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9307
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.