473,657 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using .NET Object from JavaScript

I've have a .NET Assembly, which is COM Visible. I would like to load
objects from this assembly in javascript code. E.g. Assembly Book.dll
has the class Book and I would like to use
<script language="javas cript" type="text/javascript">
var book = new Book();
document.write( book.Title);
</script>
Even more, if I could access book through the document object it would
be even more helpful, like:
<script language="javas cript" type="text/javascript">
var book = document.book;
document.write( book.Title);
</script>
Is there any way to achieve this?

Aug 23 '06 #1
4 2743
an**********@gm ail.com wrote:
I've have a .NET Assembly, which is COM Visible. I would like to load
objects from this assembly in javascript code. E.g. Assembly Book.dll
has the class Book and I would like to use
<script language="javas cript" type="text/javascript">
var book = new Book();
document.write( book.Title);
</script>
Even more, if I could access book through the document object it would
be even more helpful, like:
<script language="javas cript" type="text/javascript">
var book = document.book;
document.write( book.Title);
</script>
Is there any way to achieve this?
JSON <http://www.json.organd specifically JSON for .NET
<http://www.newtonsoft. com/products/json/(a free library) will enable
you to pass .NET objects to JavaScript with relatively little effort.

For example, something like this would probably work (although I've
never used JSON for .NET)

<script type="text/javascript">
var book = eval('(<%=JavaS criptConvert.Se rializeObject(M yBook)%>)');
alert(book.Titl e); //or whatever else you want
</script>

where MyBook is your Book object in ASPX.

Jeremy

Aug 23 '06 #2
This solution works probably in the context of a server-side dll.
It's my fault I didn't specify that the assembly is located on the
client side, it's actually a Browser Helper Object (an Internet
Explorer extension). So the question is how to bind the javascript code
to this assembly code just on the client side. It needs to work only on
Internet Explorer.

Jeremy wrote:
an**********@gm ail.com wrote:
I've have a .NET Assembly, which is COM Visible. I would like to load
objects from this assembly in javascript code. E.g. Assembly Book.dll
has the class Book and I would like to use
<script language="javas cript" type="text/javascript">
var book = new Book();
document.write( book.Title);
</script>
Even more, if I could access book through the document object it would
be even more helpful, like:
<script language="javas cript" type="text/javascript">
var book = document.book;
document.write( book.Title);
</script>
Is there any way to achieve this?

JSON <http://www.json.organd specifically JSON for .NET
<http://www.newtonsoft. com/products/json/(a free library) will enable
you to pass .NET objects to JavaScript with relatively little effort.

For example, something like this would probably work (although I've
never used JSON for .NET)

<script type="text/javascript">
var book = eval('(<%=JavaS criptConvert.Se rializeObject(M yBook)%>)');
alert(book.Titl e); //or whatever else you want
</script>

where MyBook is your Book object in ASPX.

Jeremy
Aug 23 '06 #3
Andrei Csibi wrote:
This solution works probably in the context of a server-side dll.
It's my fault I didn't specify that the assembly is located on the
client side, it's actually a Browser Helper Object (an Internet
Explorer extension). So the question is how to bind the javascript code
to this assembly code just on the client side. It needs to work only on
Internet Explorer.
In that case, I have no idea. Try asking in a Microsoft newsgroup on
msnews.microsof t.com.

Jeremy
Aug 23 '06 #4
Andrei Csibi wrote:
This solution works probably in the context of a server-side
dll. It's my fault I didn't specify that the assembly is
located on the client side, it's actually a Browser Helper
Object (an Internet Explorer extension). So the question is
how to bind the javascript code to this assembly code just
on the client side.
You may find - news:microsoft. public.scriptin g.jscript - a better place
to ask this question as this group tends towards an interest in
cross-browser scripting, for which custom browser extensions are not of
much value.
It needs to work
only on Internet Explorer.
<snip>

Don't you mean; 'it only needs to work on IE', as it would not be a
problem if it did happen to work on some other browser as well.

Richard.
Aug 23 '06 #5

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

Similar topics

28
20306
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()', this.pinginterval); - but is there no way to do this without using the literal ObjectName? If I write 'this.methodName()' I get "Line 1 Char 1: Object doesn't support this property or method." in IE, and nothing happens in Firebird.
6
2005
by: Alex Fitzpatrick | last post by:
Just by way of introduction, I'm currently the principal developer and maintainer of the a JavaScript editor plug-in for Eclipse. https://sourceforge.net/projects/jseditor/ The plug-in as it stands supports syntax highlighting and outlining of functions, classes and their methods.] When I took over the project in June it was for the purpose of adding outlining facilities for JavaScript written in an OO style with classes and so on. I...
1
6083
by: bin_P19 P | last post by:
the code i have got is as follows and now im stuck <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Shopping Cart</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="StyleSheet" href="css/style.css" type="text/css">
13
9607
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
0
6426
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to be modified: if(e.CommandName =="Print") { string parsedreceipt = null; parsedreceipt = DecodeReceipt (e.Item.Cells.Text); Session = parsedreceipt;
1
6414
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and binding it to a repeater control. This repeater control has multiple text boxes and buttons. Can you please tell me how can i do paging in this case ? I'm posting my code below. The problem is that if i click on "AdjustThisAd" button, it opens...
2
3048
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is what I'm hoping to achieve. I've never before had to use Javascript closures, but now I do, so I'm making an effort to understand them. I've been giving this essay a re-read: http://jibbering.com/faq/faq_notes/closures.html
5
2429
by: ggk517 | last post by:
We are trying to develop an Engineering application using PHP, Javascript with Informix as the back-end. Is it possible to retrieve data using Javascript but by accessing the Database. Say somebody enters part_no, than using Javascript is it possible to connect to the part master and retrieve the division and desc information? I am not allowed to use the PHP because this will require the user to insert the part number on the first...
2
1509
by: Daz | last post by:
Hi everyone. Sorry for the confusing subject, I couldn't think how best to word it. What I would like to know, is if there is an equivilant to this code, in using JSON. <script type="text/javascript"> function makeTable(number_of_rows) { var table = document.createElement('table'); table.border = 1;
6
3545
Frinavale
by: Frinavale | last post by:
Apparently I have a lot of questions today regarding JavaScript security. I've implemented a JavaScript Object that intercepts page submits (postbacks) and then displays a UI prompting the user to confirm(yes)/deny(no)/cancel(close UI/cancel submit) their action. There may be additional JavaScript methods to execute before displaying the UI and may be additional JavaScript methods to execute upon closing the UI. I'm thinking about...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
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...
1
8516
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
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...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4173
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
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
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
2
1733
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.