asp+语法介绍(二) |
|
| 2003-04-10 http://www.aspCool.com |
| |
asp+ 页面的文件和asp 一样,也是一个 文本的文件,但是他的后缀名称已经不再是 .asp 而是 .asp+
当客户端浏览器向 IIS 发出.aspx 的文件请求后,IIS 会 首先将.aspx文件编译成运行状态的NGWS 类文件来运行,请注意,这个编译的过程只在第一次运行的时候发生,以后就直接以运行态的NGWS 类运行了(和 .jsp 是不是很类似??--豆腐添加,原文没有)
一个 最简单 Asp+ 文件可以通过将 一个 html 文件的后缀名称修改为.aspx 来生成!在下面的例子中我们将作一个这样的例子
运行的范例请看这里:
http://tutorial.superexpert.com
/quickstart/aspplus/samples/webforms/intro/intro1.aspx
原代码如下:
<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>
(豆腐添加:
有的人会说,这个例子太简单了或者说根本就不是一个例子,但是对于学习来说,最起码让我们可以更深入的了解一下 asp+ 的一些神秘的外表,下面我们将要讲解一个 带有<%%>标签的粒子)
asp+文件和asp文件是兼容的,在<%%>之间我们可以使用嵌套的HTML语言,下面就是一个很简单的 和 asp 文件完全兼容 asp+ 文件
<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>
这个例子的运行请看
http://tutorial.superexpert.com
/quickstart/aspplus/samples/webforms/intro/intro2.aspx
(豆腐添加:上面这个例子演示了aspx文件和asp文件的完全兼容性,但是仅仅是这样,aspx不会成为一个新的热点,下面会简单介绍下aspx文件的一个新创的功能)
提示:和asp不同的是,在<%%>中包含的代码,是被编译执行的,而不是象asp 一样是脚本级的执行
asp+ 文件中的 <% %> 代码可以和 asp 一样动态的去修改 HTML 的输出显示使得 客户端的 内容有所改变
<%@ 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>
运行的例子在
http://tutorial.superexpert.com/
quickstart/aspplus/samples/webforms/intro/intro4.aspx
|
|
| |
|
发表评论
推荐文章
关闭窗口
|
|
|
|