IN THIS TASK
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.
- Microsoft Visual Studio .NET
- ActiveX controls
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.
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:
- Create a new ASP.NET Web Application project in Visual Basic .NET. To do this, follow these steps:
- On the File menu, click New, and then click Project.
- Under Project Types, click Visual Basic Projects.
- Under Templates, click ASP.NET Web Application.
- You now have an empty Web Form. To see the HTML version of the page, click the HTML button in the lower left of the Design window.
- Replace the existing code with the following code:
<%@ Page SmartNavigation="true" Language="vb" AutoEventWireup="false"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
x.width = 300
<form id="Form1" method="post" runat="server">
<OBJECT id="chart1" style="
Z-INDEX: 102; LEFT: 125px; WIDTH: 484px;
POSITION: absolute; TOP: 85px; HEIGHT: 200px"
onReadyStateChange = "changeWidth(this)"
- Open the toolbox, and then click the Components tab.
- Right-click in any area on the tab, and then click Customize toolbox.
- On the COM Components tab, scroll down, and then click to select the Microsoft Chart Control 6.0 (SP4) (OLEDB) check box or a similar entry.
- When you finish, a new component called MSChart appears on the Components tab. Drag this control onto the Web Form.
ID articol: 317392 - Ultima examinare: 14 iul. 2008 - Revizie: 1