How to host ActiveX controls in a Web form This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
This article was previously published under Q317392 On This PageSUMMARY This step-by-step article describes how you can host
ActiveX controls in a Web Form of an ASP.NET page. You can use the drag-and-drop feature of the Microsoft Visual Studio .NET toolbox in an ActiveX control. By using the drag-and-drop feature, you can add the OBJECT tag with the ClassID of the control to the underlying Hypertext Markup Language (HTML) code of the Web Form. NOTE: ActiveX controls that you host in a Web Form are still downloaded, installed, and run on the client side. These controls cannot run on the server side, as do Web controls. RequirementsThe following list outlines the hardware, software, network infrastructure, and service packs that are required:
Hosting an ActiveX control in ASP.NETIf you add a reference to the ActiveX control by using the Add Reference option, you can create an object of the control type in the code by using the Create Object method. That object runs on the server side, and you can invoke methods of the object. For example, if the return type of the method is binary data, you can write the binary data to the client. Use the BinaryWrite method of the Response objects.NOTE: The BinaryWrite method calls cannot be made from the client-side script. If you host an ActiveX control, and you want to access the properties and methods of the ActiveX control on the client side, you must manually modify the HTML code. The HTML code resides behind the ASPX page. By default, you are working in the Design mode of the ASPX page in the Visual Studio .NET integrated development environment (IDE). To see the HTML version of the page, click the HTML button in the lower left of the Design window. When you place an ActiveX control on the Web Form, an OBJECT tag is created in the HTML code. A client-side ActiveX control is created when the page is loaded. Because the preceding example is a pure client-side control, the server-side code cannot access this control. Server-side code can access only server controls, which are the controls that are listed on the Web Form tab in the toolbox. To determine whether a control is a server-side control or a client-side control, see the upper-left corner of the control. By default, a small green arrow in the upper-left corner of the control indicates that the control is located on the server side. Complete code for hosting a sample ActiveX control in an ASP.NET pageThe following example shows how to use the MSChart control on a Web Form in Microsoft Visual Basic .NET. This example changes the width of the chart when the page is loaded. You can view the HTML version of the ASPX page and then copy and paste the following code into the page. This action replaces the original code. To do this, follow these steps:
REFERENCES
For more information about ASP.NET server
controls, click the following article number to view the article in the Microsoft Knowledge Base:
306459 (http://support.microsoft.com/kb/306459/)
ASP.NET server controls overview
For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:http://msdn.microsoft.com/ie/ (http://msdn.microsoft.com/ie/) http://support.microsoft.com/iep (http://support.microsoft.com/iep) APPLIES TO
| Article Translations
|


Back to the top
