Windows Form in IE

xiaoxiao2021-03-06  76

If you have developed a web application using Java, you will be familiar with Java Applets, which is a small program that is basically run in the browser. When the browser loads an HTML code containing the Java Applets flag, Java Applets will execute, the operation mode of the Windows Forms control in the web page is similar to Java Applets. We can develop Windows Forms controls using the rich classes provided by Windows Forms technology, and then deploy them from the web page. When the browser loads these pages, the code contained in the Windows Forms control is executed.

One of the greatness of .NET is that it provides seamless integration capabilities with IE. For example, we can even activate a Windows Forms control from IE without knowing. Although all features of the Code Access Security provided by the .NET CLR are utilized, this is done without registration.

When developing a Windows Forms control, we have all the features provided by the Windows Forms class by inheritance. For example, we can use Windows Forms Control Verification Technology to extensively verify the data input by the user, in the same manner, we can call remote web services from the Form Control. By using all these technologies, we can use the .NET platform to develop rich and powerful applications.

achieve

In this section, we will learn how to create a simple Windows Forms control and hosted it in IE. Below is 5 steps to activate the Windows Forms control in IE:

· Create a Windows Forms control.

· Create an HTML document that contains an object flag identified by the Windows Forms control.

• Configure the virtual directory you need to correctly activate the control.

· Configure code access.

· Run the control.

Let's learn about every step in the above steps in detail.

Create a Windows Forms control

In this step, we will create a simple Windows Forms control that displays the "Hello World" information to the user. As indicated by pollorating, we will first create a new Visual C # Windows Control Library project called HelloWorldControl.

Once the project is created, we will rename the default user control to HelloWorldctl. We will add a tag control called lblMessage and a button called BTNClick. When the user clicks on the click button, the program executes the following code to display a simple information to the user:

Private void btnclick_click (Object sender, system.eventargs e) {lbldisplayMessage.text = "hello world";

Since the control has been created, let's compile the project and create an executable code. Create an HTML page

In this step, we will create an HTML document and insert an object flag used to activate the Windows Forms control. The HTML page is as follows:

Hello World Control



in the classid attribute of the object mark, we will specify a full path name, the full name of the control's control library assemblies and controls, including namespaces and controls Class name. From the above code, it can be seen that between the combined body and the control is separated from # 号, the two parameters constitute a unique control identifier that identifies the control. Since it is uniquely identified by the name HelloWorldControl1, we can write a client script code for the control.

Configure virtual directory

Once you have created an HTML code, we can create a new virtual directory called HelloWorldControlHost and add control (HelloWorldControl.dll) and HLLOWORLD.HTM. It is also important to set the execution permission of the virtual directory to Scripts in addition to configuring the virtual directory. If you are executed to Scripts & Executables, the control will not be activated correctly. By opening the Properties window of the virtual directory (below), we can verify the permissions of the virtual directory.

Configuring code access

If the control is on the Internet, it is implemented, but if you want to run the control from the Internet website, you need to configure or modify the security policy to the IE, so that it can run. This can be done by viewing the hosted web page as part of a trusted section. In order to set your site as part of the trusted section, we can use "Tools" -> "Sites" in IE, then add your site to In the list, click the "OK" button. This will then get the correct execution next time, the control is set, because the Internet license has been set.

Runput control

To run the control, just browse the HTML page hosting the control in your browser. In the displayed HTML web page, if you click the "Click Here" command button, the control will display "Hello World" as shown below.

In this example, we primarily exercise how to create a simple Windows Forms control and hosted it in IE.

转载请注明原文地址:https://www.9cbs.com/read-120121.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.054, SQL: 9