Introduction to asp+ syntax (2)---Writing our first asp+ file
Author:Eve Cole
Update Time:2009-05-30 19:54:18
The file of the asp+ page is the same as asp. It is also a text file, but its suffix name is no longer .asp but .asp+
When the client browser sends an .aspx file request to IIS, IIS will first compile the .aspx file into a running NGWS class file for operation. Please note that this compilation process only occurs during the first run. From now on, it will be run directly with the NGWS class in the running state (is it very similar to .jsp??--Tofu added, not in the original text)
The simplest Asp+ file can be generated by changing the suffix name of an html file to .aspx! In the following example we will make one such example. See here for an example of running it:
http://tutorial.superexpert.com/quickstart/aspplus/samples/webforms/intro/intro1.aspx
The original code is as follows:
<html>
<head>
<link rel="stylesheet"href="intro.css">
</head>
<body>
<center>
<form action="intro1.aspx" method="post">
<h3> Name: <input id="Name" type=text>
Category: <select id="Category" size=1>
<option>psychology</option>
<option>business</option>
<option>popular_comp</option>
</select>
<input type=submit value="Lookup">
</form>
</center>
</body>
</html>
(Tofu added:
Some people will say that this example is too simple or not an example at all, but for learning, at least it allows us to have a deeper understanding of some of the mysterious appearances of asp+. Below we will explain an example with < %%> label particles)
ASP+ files are compatible with ASP files. We can use nested HTML language between <%%>. Here is a very simple ASP+ file that is fully compatible with ASP files.
<html>
<head>
<link rel="stylesheet"href="intro.css">
</head>
<body>
<center>
<form action="intro2.aspx" method="post">
<h3> Name: <input id="Name" type=text>
Category: <select id="Category" size=1>
<option>psychology</option>
<option>business</option>
<option>popular_comp</option>
</select>
<input type=submit value="Lookup">
<p>
<% for i=0 to 7 %>
<font size="<%=i%>"> Welcome to ASP+ </font> <br>
<% next %>
</form>
</center>
</body>
</html>
Please see the operation of this example
http://tutorial.superexpert.com/quickstart/aspplus/samples/webforms/intro/intro2.aspx
(Tofu addition: The above example demonstrates the complete compatibility of aspx files and asp files, but it is just this. aspx will not become a new hot spot. The following will briefly introduce a new function of aspx files)
Tip: Unlike asp, the code contained in <%%> is compiled and executed, rather than script-level execution like asp.
The <% %> code in the asp+ file can dynamically modify the HTML output display like asp to change the content on the client.
<%@ Page Language="VB" %>
<html>
<head>
<link rel="stylesheet"href="intro.css">
</head>
<body>
<center>
<form action="intro3.aspx">
<h3> Name: <input name="Name" type=text value="<%=Request.QueryString("Name")%>">
Category: <select name="Category" size=1>
<%
Dim I As Integer
Dim Values(3) As String
Values(0) = "psychology"
Values(1) = "business"
Values(2) = "popular_comp"
For I = 0 To Values.Length - 1
%>
<% If (Request.QueryString("Category") = Values(i)) %>
<option selected>
<%Else%>
<option>
<% End If %>
<%=Values(i)%>
</option>
<% Next %>
</select>
<input type=submit name="Lookup" value="Lookup">
<p>
<% If (Not Request.QueryString("Lookup") = Null) %>
Hi <%=Request.QueryString("Name") %>, you selected: <%=Request.QueryString("Category") %>
<% End If %>
</form>
</center>
</body>
</html>
Running example is at
http://tutorial.superexpert.com/quickstart/aspplus/samples/webforms/intro/intro4.aspx
ASP+ also has many new features, which I will continue to introduce at the appropriate time!
Please continue to support us!