Outside XAML, HTML Document Object Model on .NET Form
Author: liang bo
Brianliangx@hotmail.com
We want an application's UI to be edited at runtime, so that it can be performed at any time. Microsoft uses XAML in the longhorn programming model to provide a description mechanism for user interfaces, but now HTML web pages also have such features. Compared to traditional Windows Form, the web page is more beautiful, colorful, dynamic, of course, we don't just need beauty, we have to make the web page can interact together with other parts of the window, and there is no different window control.
Before reading this article, the author wants you to have the following technical foundation: (1) Be familiar with at least one .NET language (2) There are some understanding of the webpage, and can use tools such as FrontPage or Dreamweaver production [this is not required, even You are not familiar with the web production, maybe someone in your friend is fine in this way] (3) JavaScript or vbscript scripting base [This is not required, you can refer to the code example of the article to write them]
Finally, you need to get TZ Web-Style Form Control controls. It provides an extended document object model that helps developers get the host window object of the browse page, and call the method, pass the parameters. You can also replace the right-click menu of the web page using the application's right-click menu to keep the application's style consistent. You can download this control here:
http://www.appTemplate.com/downloads/tzwbc.asp
1. Transfer parameters to .NET FORM using the HTML control
Let's make a simple web page, use TZ Web-Style Control to browse it, and fill the Form window as the user interface. In addition to the background image, we
(1) Add two single-line text box controls in the web page, named TXTMSGTITLE, TXTMSGCONTENT, and the code is as follows:
Name = "Button2" Language = "JavaScript" οnclick = "Return Button2_onclick ()">
(2) Add the following code in the
head> tag of the HTML file:
WINDOW.EXTERNAL.MSGBOXSHOW (TXTMSGTILE.VALUE, TXTMSGCONTENT.VALUE);
// ->
Window.external Gets the host Form object for the browser control, calls its msgboxshow method, you can also use the following code:
/ ***************************************
Var AppObj;
Function window_onload () {
AppOBJ = WINDOW.EXTERNAL; // Get Host Application ObjectAppobj.msgboxshow (txtmsgtitle.value, txtmsgcontent.value);
****************************** /
(3) Add a TZ Web-Style Form Control in the Form1 window, set the Dock property to Fill, set up URL_OPPOSITE for Index.htm so that he can browse the index.htm web page under the same directory in the application. Add functions in Form1.cs
Public void msgboxshow (String Title, String Content)
{MessageBox.show (title, content, system.windows.forms.MessageboxButtons.yesno, system.windows.forms.MESSAGEBOXICON.INFORMATION);
}
Note that the method must be declared as public.
Place the application's executable and web files in the same directory, run:
2. Application of Microsoft Money style
In this application, we use a TZ Web-Style Form Control at the top of the window, with it to browse a local page, please refer to the attachment or email to me for the specific code. In the web page, I inserted a 6 * 2 table placement flip picture (the first picture is displayed when the page is transferred, and the second picture is displayed after the mouse is stopped) and the text. In order to change the table with the change in the window (strictly speaking, with the change in control size), we set the width of the table to 100%: