Skip to main content

Posts

Showing posts with the label usercontrol

ActiveX Stopwatch Timer Control

Here's an example of a StopWatch control implemented in Csharp and used as a control on a web client. The control needs to be register on the clients machine then added to the clients web application (in html) and then called from Javascript. <OBJECT id="activeXTimerControl" name="activeXTimerControl"  classid="clsid:4F3B57CE-D9CA-41c3-ACBD-EBB2380990E7"  style="width: 504px; height: 182px"  codebase="Bin/ActiveXTimerControl.dll" class="ActiveXTimerControl.TimerControl"> </OBJECT> To start the Stopwatch call Start() and to end call End() then call Time() to return the result as a string or use the AddTimeToGrid to add the time to a DataGrid Control (supplied by the StopWatch control) or call AddTimeToLabel which adds the time to a textbox. activeXTimerControl.Start(); ///do someting activeXTimerControl.Stop(); var time = activeXTimerControl....

AcitveX Controls - how to create one and call with Javascript

One way to get a .NET object to run in a browser is to create a User Control in .NET. You can then call this User Control from Javascript in your client. 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. public void AddText(string time) { if (_timerTextBox == null) { _timerTextBox = new System.Windows.Forms.TextBox(); _timerTextBox.Text = " Time (msec)"; } _timerTextBox.Text += ("\r\n" ...