asp+语法介绍(二)---书写我们的第一个asp+ 文件

  • 来源: 互联网 作者: 若水   2008-03-17/11:32
  • 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#p#分页标题#e#
    (豆腐添加:上面这个例子演示了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) %>#p#分页标题#e#

                  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

    asp+还有很多新的特点,我我会在合适的时间继续介绍的!
    请大家继续支持我们!


    评论 {{userinfo.comments}}

    {{money}}

    {{question.question}}

    A {{question.A}}
    B {{question.B}}
    C {{question.C}}
    D {{question.D}}
    提交

    驱动号 更多