473,809 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help: Win Controls Hosted in IE - Cannot pass/retrieve parameters in JS

Hi all,

I built a Windows Froms user control and I use it in IE 6+. It
functions properly (it displays properly in IE and executes code, such
as displaying a message box), except that in the web page I cannot do
any scripting (javascript) against it. This control has a public
property Text2, which is initialized properly:
<object id="simpleContr ol1"
classid="http:W inControlCS.dll #WinControlCS.W inControl"
height="300" width="300" VIEWASTEXT>
<param name="Text2" value="123" />
</object>

However, when I try to get/set this property in JS, it won't work, I
get 'undefined':
<script>
function ChangeText() {
text1.value=sim pleControl1.Tex t2;
}

</script>

If I don't specify the property Text2, I get '[object]':
<script>
function ChangeText() {
text1.value=sim pleControl1;
}

</script>

This suggests me that the object simpleControl1 exists, but I just
don't know how to access the Text2 property in JS.

I set full trust for the Local Intranet, no luck.

FYI, there is a sample online at gotdotnet and if I point the browser
to it, it works:
http://samples.gotdotnet.com/quickst...s/IeSourcing/V...
This example passes a value to the Text property of the control,
similarly with I'm trying to do.

I tried with and without this line with no luck: <param name="Text2"
value="123" />

I tried a builtin property, BackColor, with exactly the same result: It
can be initialized, but it cannot be changed in JS.

I tried with controls written in both C# and VB. Here is the C#
version:
using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Drawing;
using System.Text;
using System.Windows. Forms;

namespace WinControlCS
{
public partial class WinControl : UserControl
{
public WinControl()
{
InitializeCompo nent();
}

private void WinControl_Load (object sender, EventArgs e)
{

}

public string Text2
{
get { return richTextBox1.Te xt; }
set { richTextBox1.Te xt = value; }
}

private void button1_Click(o bject sender, EventArgs e)
{
MessageBox.Show (richTextBox1.T ext);
}

private void openToolStripMe nuItem_Click(ob ject sender,
EventArgs e)
{
MessageBox.Show ("Click File/Open");
}
}

}

I use VS 2005 on XP sp2.

Please help. I am stuck as I don't find any information on newsgroups.
Thanks
Tom

Sep 9 '06 #1
2 1567
Is anyone from Microsoft who can help me with this? Do you need more
details? In the end, is it possible to get/set properties of a Windows
Forms control hosted in IE using JavaScript? If yes, what do I do
wrong?
Thanks a bunch,
Tom

Sep 11 '06 #2
You need to create a public interface and register the assembly for COM
interop in order to assign properties via Javascript

i.e.

// you are going to want to check my Syntax im a VB guy
public interface IWinControlCS{
public string Text2;
}

"to********@yah oo.com" wrote:
Hi all,

I built a Windows Froms user control and I use it in IE 6+. It
functions properly (it displays properly in IE and executes code, such
as displaying a message box), except that in the web page I cannot do
any scripting (javascript) against it. This control has a public
property Text2, which is initialized properly:
<object id="simpleContr ol1"
classid="http:W inControlCS.dll #WinControlCS.W inControl"
height="300" width="300" VIEWASTEXT>
<param name="Text2" value="123" />
</object>

However, when I try to get/set this property in JS, it won't work, I
get 'undefined':
<script>
function ChangeText() {
text1.value=sim pleControl1.Tex t2;
}

</script>

If I don't specify the property Text2, I get '[object]':
<script>
function ChangeText() {
text1.value=sim pleControl1;
}

</script>

This suggests me that the object simpleControl1 exists, but I just
don't know how to access the Text2 property in JS.

I set full trust for the Local Intranet, no luck.

FYI, there is a sample online at gotdotnet and if I point the browser
to it, it works:
http://samples.gotdotnet.com/quickst...s/IeSourcing/V...
This example passes a value to the Text property of the control,
similarly with I'm trying to do.

I tried with and without this line with no luck: <param name="Text2"
value="123" />

I tried a builtin property, BackColor, with exactly the same result: It
can be initialized, but it cannot be changed in JS.

I tried with controls written in both C# and VB. Here is the C#
version:
using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Drawing;
using System.Text;
using System.Windows. Forms;

namespace WinControlCS
{
public partial class WinControl : UserControl
{
public WinControl()
{
InitializeCompo nent();
}

private void WinControl_Load (object sender, EventArgs e)
{

}

public string Text2
{
get { return richTextBox1.Te xt; }
set { richTextBox1.Te xt = value; }
}

private void button1_Click(o bject sender, EventArgs e)
{
MessageBox.Show (richTextBox1.T ext);
}

private void openToolStripMe nuItem_Click(ob ject sender,
EventArgs e)
{
MessageBox.Show ("Click File/Open");
}
}

}

I use VS 2005 on XP sp2.

Please help. I am stuck as I don't find any information on newsgroups.
Thanks
Tom

Nov 4 '06 #3

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

Similar topics

8
5484
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
9
2418
by: hope | last post by:
Hi Access 97 I'm lost on this code please can you help ================================= Below is some simple code that will concatenate a single field's value from multiple records into a single string separated by a user defined character. There is no error trapping (by design), USE AT YOUR OWN RISK.
6
1485
by: JSheble | last post by:
I come from a Delphi background, and am currently trying to port or convert some of our Delphi classes to C#. I've got a good handle on basic class design, but am a bit lost with some of the more advanced things I need to do, and was hoping somebody could point me to an online resource that can help me better understand what I need to do. For example, one of the classes is a Shipment class. A Shipment can have any number of Packages,...
4
1963
by: Doruk | last post by:
The problem that we are experiencing is simple: We want to pass certain parameters from a page with several server controls to another page. We want to do this in a dotnet compliant manner, but we can't seem to find a good and clean solution anywhere. The options we looked into are as follows. Comments following the options are why we did not want to go with them:
4
3585
by: Charles Law | last post by:
Hi guys. I have two threads: a main thread and a background thread. Lots of stuff happens in the background thread that means I have to update several (lots) of controls on a form. It is quite tiresome to have to write code to call MyControl.Invoke for each control on the form, along with the delegates that are required for each. Is there a better way to do this? What I mean is, if I could marshal the
4
2474
by: Warren Sirota | last post by:
Hi, Please let me know if I am interpreting this correctly. I've done a little testing of the difference between passing parameters byVal and byRef, and the results were slightly non-intuitive, as I expected. I haven't seen this behavior explained precisely in the .net world yet, so I wanted to check and make sure I've got it right. I apologize that this is a bit long. I've tried to keep it concise. There are code fragments here, but...
0
1281
by: r1 | last post by:
I am relatively inexperienced in using delegates and asynchronous methods. I read several articles, and then I developed my own code with a mission to improve the performance. Wow! I cannot believe the difference in speed! However, the asynch operation fails sometimes, despite of the fact that it works most of the time. I am really at a loss how to fix this sporadic and erratic behavior. This is a web application developed with...
7
9719
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason for this being to stop the user thinking the application has frozen when in fact it is just waiting for a long SP to complete. Another reason for doing it like this is that I also have had a problem in the past where the SP takes longer than the...
0
5578
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
0
9721
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
10633
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
10376
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
10375
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
9198
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...
1
7651
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
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
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
3011
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.