• 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>

  • 相关阅读:
    解决AJAX中使用UpdatePanel后再用无法弹出对话框问题
    <转>JavaScript 参考教程资料之文档对象
    C#中图片的重绘
    csv数据源的创建(二)
    开始试用windows live writer
    与BW相关各模块常用tcode及Table
    SAP中的client(也叫集团)的意义
    SAP中的client(也叫集团)的意义(中文版)
    BW报表igs服务配置解决中文显示问题
    开源.net论坛有那些?
  • 原文地址:https://www.cnblogs.com/soldierback/p/11703702.html
Copyright © 2020-2023  润新知