zoukankan      html  css  js  c++  java
  • ASP学习笔记1

    一、变量

      1.1 声明变量

      dim name
      name="Donald Duck"
      response.write("My name is: " & name)
      1.2 声明数组

      Dim famname(5),i
      famname(0) = "Jan Egil"
      famname(1) = "Tove"
      famname(2) = "Hege"
      famname(3) = "Stale"
      famname(4) = "Kai Jim"
      famname(5) = "Borge"

      For i = 0 to 5
          response.write(famname(i) & "<br>")
      Next

    二、函数

      2.1 VB

      <!DOCTYPE html>
      <html>
        <head>
          <%
            sub vbproc(num1,num2)
              response.write(num1*num2)
            end sub
          %>
        </head>
        <body>
          <p>Result: <%call vbproc(3,4)%></p>
        </body>
      </html>

      2.2 JS

      将 <%@ language="language" %> 这一行写在 <html> 标签的上面,就可以使用另一种脚本语言来编写子程序或者函数:
      <%@ language="javascript" %>
      <!DOCTYPE html>
      <html>
        <head>
          <%
            function jsproc(num1,num2)
            {
              Response.Write(num1*num2)
            }
          %>
        </head>
        <body>
          <p>Result: <%jsproc(3,4)%></p>
        </body>
      </html>
      
      2.3 在一个 ASP 文件中调用 VBScript 子程序和 JavaScript 子程序
      
      <!DOCTYPE html>
      <html>
        <head>
          <%
            sub vbproc(num1,num2)
              Response.Write(num1*num2)
            end sub
          %>

          <script  language="javascript" runat="server">
            function jsproc(num1,num2)
            {
              Response.Write(num1*num2)
            }
          </script>

        </head>
        <body>
          <p>Result: <%call vbproc(3,4)%></p>
          <p>Result: <%call jsproc(3,4)%></p>
        </body>
      </html>
    三、表单

      3.1 GET表单(index.asp)

      <!DOCTYPE html>
      <html>
        <body>
          <form action="index.asp" method="get">
            Your name: <input type="text" name="fname" size="20" />
            <input type="submit" value="Submit" />
          </form>
          <%
            dim fname
            fname=Request.QueryString("fname")
            If fname<>"" Then
                Response.Write("Hello " & fname & "!<br>")
                Response.Write("How are you today?")
            End If
          %>

        </body>
      </html>
      
      
    3.2 POST表单(index.asp)
      
      <!DOCTYPE html>
      <html>
        <body>
          <form action="demo_simpleform.asp" method="post">
            Your name: <input type="text" name="fname" size="20" />
            <input type="submit" value="Submit" />
          </form>
          <%
            dim fname
            fname=Request.Form("fname")
            If fname<>"" Then
                Response.Write("Hello " & fname & "!<br>")
                Response.Write("How are you today?")
            End If
          %>

        </body>
      </html>
    四、Cookie
      
      4.1 创建cookie
      <%
        Response.Cookies("firstname")="Alex"
        Response.Cookies("firstname").Expires=#May 10,2012#
      %>

      4.2 取回cookie
      <%
        fname=Request.Cookies("firstname")
        response.write("Firstname=" & fname)
      %>

      4.3 带有键的cookie
      <%
        Response.Cookies("user")("firstname")="John"
        Response.Cookies("user")("lastname")="Smith"
        Response.Cookies("user")("country")="Norway"
        Response.Cookies("user")("age")="25"
      %>

      4.4 读取所有cookie
      I. 被读取的cookie
      <%
        Response.Cookies("firstname")="Alex"
        Response.Cookies("user")("firstname")="John"
        Response.Cookies("user")("lastname")="Smith"
        Response.Cookies("user")("country")="Norway"
        Response.Cookies("user")("age")="25"
      %>
      II. 读取cookie
      <!DOCTYPE html>
      <html>
        <body>

        <%
          dim x,y
          for each x in Request.Cookies
            response.write("<p>")
            if Request.Cookies(x).HasKeys then
              for each y in Request.Cookies(x)
                response.write(x & ":" & y & "=" & Request.Cookies(x)(y))
                response.write("<br>")
              next
            else
              Response.Write(x & "=" & Request.Cookies(x) & "<br>")
            end if
            response.write "</p>"
          next
        %>

        </body>
      </html>

  • 相关阅读:
    pm3
    算法交易系列研究之一
    CDS究竟是个什么鬼?它直接导致了次贷危机?
    源特定组播(SSM:Source Specific Multicast)
    投资交易系统常用表
    交易系统解析(六)前台报盘应用设计要点
    人物
    句子
    康德拉季耶夫周期
    非标
  • 原文地址:https://www.cnblogs.com/soldierback/p/11703702.html
Copyright © 2011-2022 走看看