WebClass implementation of dynamic web programming practices

zhaozj2021-02-08  231

WebClass dynamic WEB Programming Practices articles (Author: Suhongtu Super 2001 at 15:50 on January 10) said so many things about the WebClass theoretical aspects, surely we'll want to try it yourself exactly how WebClass is like a After going back, then we will first look at a small example, and slowly digest the various theoretical knowledge we have explained above: After starting the VB6 integrated environment, new projects "IIS Application" project. This default will create a name that is Project1 and a default WebClass object called WebClass1. WebClass's development environment has two components: WebClass designer and code window. The status of the WebClass designer is like the usual VB form designer, and you can add a new HTML template WebItems, add a Custom WebItems object, and add a variety of event processing procedures to WebItems and start the local Web Server. When this project is running, the WebClass object will be initialized, which will trigger the WebClass_start event, which means that this event is similar to the Sub Main function in VB, he will be triggered. Let's write a first simple WebClass program code: Option expedition Option Compare text private sub webclass_start () response.write "" response.write "" response.write "

This is our A WebClass program! "response.write"
Current system event is: "& now () &" "response.write" "response.write" "End Sub is good, we need to save this project, VB will prompt us to build a new Web when running, in order to run our WebClass project in VB. After that, we run this project, VB will automatically call the Internet Explorer browser to browse our programs, and you can set the endpoint at our webclass program to track the values ​​of various variables, which cannot be in a normal ASP program. Imagine things, but using WebClass is so convenient and free! WebClass uses WebITEM to provide content and events to your browser. Each WebClass will contain multiple webitems. WebItem has two types: HTML Template WebItem and Custom WebItem. With HTML Template WebItem, you can link HTML files and WebItem, so you must create the HTML file we need before adding WebItem.

It is worth noting that when you add an HTML template, if the template file and our project file are not in the same directory, the system copies a copy of the template to the directory where the project is located; if the template file and engineering file In the same directory, the system renames the name of this template, and we need to change the copy of this template when you need to change the template, not it itself! WebITEM uses method WriteTemplate () to output template for the response. Let's take a look at a program that combines HTML Template WebItem: Add an HTML Template WebItem that we just added, the system will prompt us to choose an HTML file, we choose the HTML file is test.htm, the content is simple: < HTML>
This is the contents of the template test: Hello, World! We will find name "Template1" in "HTML Template WebItem" in the WebClass designer "One template, for convenience, we change his name" TEST ". So our code changes as follows: Option Explicit Option Compare Text 'Template Test's Response Events Private Sub Test_Respond () Response.write "


Temponic Test" "Call WriteTemplate Method to deal with our HTML template file called TEST TEST.WRITETEMPLATE End Sub Private Sub WebClass_Start () 'Write a token Response.Write "" Response.write "

" response .write "
This is our first WebClass program! " response.write "
Current system event is:" & now () & "" Response.write " "Response.write" "will give the control to the HTML template called TEST, which will first trigger his response event set next subclass = test end subride us run this WebClass program , Will be displayed in the browser (Figure 1): Next, let's take a look at Custom WebItem, this type of WebItem does not have a related HTML file, as the name suggests, he is a user-defined WebItem, he can't use WriteTemplate ( Method. It can also be triggered by setting the next ITITEM property. We will no longer be repeated.

During two types of WebItem, let's take a comprehensive use of these two types of WebItem: Option Explicit Option COMPARE TEXT Private Sub customer_respond () response.write


User Custom WebItem (Custome) Response event response! "Response.write"

Next handles the user's choice! "Handling the selection of the user Select Case Trim (Request.form (" Userchoice) ) Case "ordinary workers" Set NextItem = workerpage Case "salesperson" Set NextItem = salespage Case "other" Set NextItem = otherpage End Select End Sub Private Sub otherpage_Respond () Response.Write "


template otherpage of response incident response! "otherpage.WriteTemplate End Sub Private Sub salespage_Respond () Response.Write"


template salespage the response incident response! "salespage.WriteTemplate End Sub Private Sub workerpage_Respond () Response.write "
"
Template WorkerPage "Response Event Response! " WorkerPage.writeTemplate End Sub Private Sub Webclass_Start () 'WebClass starts to generate a form with response .write "

".write"
processing table Single
"Set Form Submit to our Custom WebItem (Custom), first triggered the Custom's Response event .Write"
" .Write "Select your favorite career: ".write" "End with end Sub's three HTML The template is as follows: html template OtherPage:

You choose another occupation! HTML template SaleSpage: and is indeed Replace it! Through the contact of the above explanation and the actual example, I believe that everyone has a certain understanding and understanding of WebClass's programming ideas and ideas. Of course, our article is just guiding everyone to enter the WebClass world, and the real webclass program still needs everyone's constant practice. You can master it, but you must know how to use our brief introduction, you must know that WebClass is a great leap in WebClass relative to pure ASP. He makes we can write a variety of webs from us to write ordinary applications. Program, bring us great convenience! We can use all VB programs in the world of WebClass, including all kind of ActiveX DLL objects, etc., you can enjoy all the advantages brought by VB! At the end of the article, let's take a look at some "secrets" achieved by WebClass, and it is still using our example. Our project is saved as Project1, and WebClass is named WebClass1, then you will run this project, you will It is found that it is displayed in the URL in the middle of the browser: http://localhost/project1/webclass1.asp.

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

New Post(0)