views:

55

answers:

2

Hi, I am trying to use my .net image editor user control as an activeX object in a web form.

After internet search, I created a asp.net web site from VS2008 and added the following code

<object classid="res/ImageEditor.dll#ImageEditor.Editor" 
        height="400" width="400" id="myControl1" name="myControl1" > 
</object>

<INPUT id="Button1" type="button" value="Btn" name="Btn" onclick="return Button1_onclick()">

</script>
<script language=javascript>
    function Button1_onclick() {
        alert(document.getElementById("myControl1").WatermarkText);
    }
</script>

I have two problems

1-) When i first create the project i see the user control on browser but, after rebuilding the user control and changing the dll file at web site, the object no more appears on browser. Instead i see something like an error image.

2-) i can not access public properties.

The user control is marked as "make com visible", and register for com is checked at properties.

A: 

There are quite a few hoops to jump through in order to get a .NET UserControl to behave nicely as an ActiveX.

See my answer to this previous question, on how to get it working.

To add more clarity on why you're having problems with building your UserControl, you've probably got the auto build number going in your project properties. "Hard code" the version number in the properties. As long as you don't change interface you should be fine.

N.B. You have to implement a public IDispatch interface for your properties to be accessable.

ParmesanCodice
Thanks your answer explains my upcoming questions about events. But i need to solve the first problem in order to be able to try things. I am creating a new web site project for every change in dll.
Ali YILDIRIM
@Ali YILDIRIM if you keep the same version number and GUID's you shouldn't need to make a new project every time. If you change the interface however, you'll need to rev your ActiveX.
ParmesanCodice
A: 

Signing the user control solved the problem. Thanks for your time.

Ali YILDIRIM
Yip forgot about that gotcha! There are so many when doing ActiveX in .NET :(
ParmesanCodice