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