What is the difference between ASP and ASP: http://www.aspcn.com The original text from http://www.asptoday.com See the translation of the headache, and this article is still very long, this article is very It will be written as soon as possible for a few days, but run to the body, or lose. . . . . . .
In the previous article, we recognize that ASP is part of a complete operating system. But why is ASP different from previous version of ASP? What is the difference between them? If you are just running some pages or applications, you may not notice their previous differences at all.
Once you open the ASP SDK or help file, you will find that this new product is almost no bit like the previous version.
Of course, we don't have to panic. Let's take a look at some main points. Let's take a look at why Microsoft will think that we need a new version of ASP, which can help us do. As a developer, we also have to know which new features are to help us establish site and application.
We really need a new ASP! ?
Microsoft has developed ASP motivation. We have discussed in the previous article. ASP has made great success, why do we need a new version! ? We can consider it from below:
The current ASP can only be written in a non-structural language, such as VBScript and JScript (if you need a separate interpreter) if other languages. Moreover, when the ASP is executed for the first time, it resolves and stores these code in Cache, which is not allowed to use other structural languages such as VB and C , limiting their superiority. ASP truly provides the middle language execution structure, allowing the use of various languages. Use HTML, text, and object-mixed ASPs easy to create a large page. But it is difficult to reuse these code unless you put some code in an Include file. This is not the best solution. In a lot of occasions, developing a network application requires a wide range of professional skills, such as you write the program, others do the art, and some people design web pages, if only ASP is difficult to connect these people to complete The same thing. However, ASP actually allows individual code to coexist with content.
In the ASP in previous versions, you must write code for almost everything. In order to keep the data in the form, write the code. In order to confirm the data written in the user, write the code. In order to send some simple data, write code. In the ASP , a real component mode is introduced. Through this server-side control and event trigger, we seem to feel like "form" in operation VB. This ASP new component control is the nature of the declaration ( That is, if you want to use these component controls to do something, you only need to declare it, don't worry, haha, if you think some fools ?!?), You actually need to write Very few code. In fact, in many cases, you don't have to write any code at all. The world is changing, and there is a considerable proportion of users to access your site through "Internet equipment". Say WAP mobile phones, PDAs, top boxes, and others, maybe in the near future, users who use these Internet users more than using PCs. This means that we may have to do more in the server to fit in different devices. We have to use different formats, such as WML. At the same time, new internet equipment and commercial applications also need to be able to send or read WML from web applications. Now use ASP to do this, you need to use XML parsers to use XML conversion data. The ASP network service will use the simple manner to use the page you can adapt to different devices. In addition to these, rapidly developing distributions are applications that need to be developed more quickly, more modular, repeated utilization, easier to operate, so more platform support. New standards such as SOAP (Simple Object Access Protocol) and the commercial needs of B2B require a new technology to adapt to different systems. Web applications and websites need to provide a more powerful upgradeable service, ASP can adapt to the above requirements, and can restart the application when an error occurs, buffer overflows.
Therefore, in order to adapt to these needs, ASP has been repaired based on the basis even the development environment. Visual Studio 7.0 will be completed for ASP applications (including ASP and ASP ), although there are only few tools now get their support. This rich, component mode program development module is designed to be quite friendly, and it also supports all Visual Studio languages, including VB, C , and C #, especially pay attention to the third language, its popular days are not too far away .
How does ASP make your life simpler?
The biggest challenge for today's web programmers is to changing the compatibility of the browser, and their constant upgrade. In the guaranteed page, you can use the latest properties of each browser while working at all popular browsers, which is simply a nightmare.
More terrible is to establish different web pages for different user equipment. Of course, it is impossible to establish equivalent levels on WAP phones and traditional browsers, because due to bandwidth, only 12 words 3 lines of text information can only be displayed in many WAP phones.
A simplest solution is to dynamically generate different outputs for different users, or write multiple pages for different users. The second method is not efficient, I think most developers will choose the first method. But this means that every click of the user will make the server to determine what should be displayed to the user.
If all this is possible, why not automate these processes! ? In order to end this, ASP introduces a new service control concept, which encapsulates some common tasks, providing a clear programming module. They also help manage different user types. Server-side HTML control makes us reduce a lot of code
The ASP has provided a capacity to execute components on the server, which can generate some code to return to the user. ASP inherits this concept through service control. The need to convert HTML elements to service control is just an additional property: runat = "server" (this we have seen in ASP)
Any HTML element in the page can be marked with this method, and ASP will perform these elements on the server and produce different code for different users.
This concept that allows HTML elements to execute on the server. The first time it seems to be somewhat strange, but when you find it completely functionalized in this page, what else do you want to do.
Keep state problem
One of the most annoying questions when we build interactive pages and applications is to process data from the client and then keep these data to control. A core objective of ASP is to simplify this process. This will not give any confusion to the programmer and work properly on most browsers.
Let's take a look at the code below. This code has created a simple page to allow users to enter the name of the computer and select the operating system. OK, it is not a very annoying example, but it reflects some things we often do. When this page is submitted, use the request.form set to obtain the corresponding data and then display them with Request.write.
<%
IF LEN ("SELOPSYS")> 0 THEN
Stropsys = Request.form ("SELOPSYS")
Strname = Request.form ("txtname")
Response.write "You SELECTED '" & stropsys _
& "'for machine'" & strname & "'."
END IF
%>
Machine Name:
Operating system:
Form>
Body>
Html>
We use the code below in ASP creation
...
Form>
When this page is executed by ASP , the code output to the browser is:
...
Form>
You now see ASP automatically add Action and Method methods, so this page will be submitted in a POST mode. ASP also adds a unique value ID and Name value to Form, and these we have not specified (but you can also specify, you specify as you specify)
If you are adding the "get" attribute, this form will be received in queryString, just like the previous ASP, this automatic state will not work.
In this page we use the code below to establish a text item:
The result in the browser is:
You can also see ASP automatically add the value attribute and its value. At the same time, the Name property is added, which is the same as the value of the ID.
Here is
Select>
ASP because there is a selected attribute in
Here, the ID attribute is again established, and the value of the value element in
So, as you can see, there is no ghost trick here, here is a standard HTML, there is no client's script library, and there is no ActiveX or Java Applets.
ASP server code
In order to display these values in the page, we use the code in the ASP example:
...
IF LEN ("SELOPSYS")> 0 THEN
Stropsys = Request.form ("SELOPSYS")
Strname = Request.form ("txtname")
Response.write ("You SELECTED '" & stropsys_
& "'for machine'" & strname & "'.")
END IF
...
Another huge advantage of ASP and service control is to perform code on the server and create an output. ASP emphasizes that each element has only one unique ID attribute, so service control (that is, Runat = "Server" elements must rely on the original code. This means that we don't need to use the Request collection to access the values from the client, just use the unique ID.
...
IF LEN (SELOPSYS.VALUE> 0 THEN
Response.write ("You SELECTED '" & SELOPSYS.VALUE _
& "FOR Machine '" & TXTName.Value & ")
END IF
...
VB code in ASP
In the ASP page we just saw, the scripting language is VBScript (it is not unique, but if there is no other setting, then it is the default language). In ASP , it does not support VBScript no longer support VBScript. It's a default language is Visual Basic (VB), so our code will be compiled into an IL (Intermediate Language).
In the new VB7.0, VB's compiler already includes ASP (haha, is there a good news, we don't need to buy Dongdong). In this new version, a most worthwhile is that all methods in VB7 must have a list of parameters included in parentheses. This requirement is not required in VBScript and previous VB versions.
The execution of the server event.
Of course, if you want some HTML elements to execute on the server, then why don't you expand this concept? ! ASP has turned each page into a server object, and provides a lot of properties, methods, and events, which can be well used in your page. Each page becomes a node on a COM object that can be operated and written independently when they are requested.
Use server-side control events
Look at the following code, see how we use the advantages of ASP to perfectly structure our page.
Sub ShowValues (Sender As Object, Args As Eventargs)
DivResult.innertext = "you selected '"
& sellsys.value & "'for machine'" _
& txtName.Value & "'."
End Sub
Script>