There's nothing magical about this except, it only works on IE and there are a few small bits that you must implement in order for your User Control to be picked up, the errors you get aren't very helpful so I recommend following these steps (Some of these I'm not sure if they're required but they've worked for me).
- Create a Class Project in Visual Studio 2005.
- Add a User Control to the project.
- In the User Control Designer add a TextBox Control
- Add a Property to your class to set the Text of the TextBox you've just added.
if (_timerTextBox == null)
_timerTextBox = new System.Windows.Forms.TextBox();
_timerTextBox.Text = " Time (msec)";
_timerTextBox.Text += ("\r\n" + time);
- Create an Interface in the same namespace as your UserControl and add the signature of the Property you've just added.
void AddText( string time);
- Mark the Class with a the GuidAttribute and also inherit it from the interface you've just created.
public partial class TimerControl : UserControl, IActiveXTimerControl
- Mark the Assembly as Com Visible in the Project Properties "Assembly Information".
- Compile this and register it by adding a Post-Build Event to your project
- regasm $(TargetFileName) /tlb /codebase
You now have an Assembly which has a control usable in a browser.
Now to use this Control
Create a website and add the following aspx page (the content of this could also be in html page) inside the body
var time = "some time";
Note the clsid above this is crucial it must be the same GUID value as you gave the Class.