ASP學習:ASP頁面開發技巧

來源:互聯網
上載者:User
技巧|頁面     ASP(Active Server Page)為製作動態網頁面提供了強有力的支援人員。在ASP頁面中可以有多個提交按鈕提交不同的資料,執行不同的操作,而這些都返回同一個ASP頁面。以下是一個對汽車展場資料庫執行查詢(尋找新ID號)、更改和添加的程式,代碼如下:

  ′程式caredit.asp

  〈script LANGUAGE=″vbscript″ RUNAT=″Server″〉

  ′當轉到FP98下時,下面的″返回″兩個漢字不會成亂碼

  〈/script〉

  〈%if Request.Form(″cmdback″)=″返回″ then

  ′點擊cmdback按鈕跳轉到carqry.asp頁面

Response.Redirect ″carqry.asp″

  end if%〉

  〈html〉

  〈head〉

  〈meta http-equiv=″Content-Type″ content=″text/html; charset=gb_2312-80″〉

  〈meta name=″VI60_defaultClientScript″ content=″JavaScript″〉

  〈meta name=″GENERATOR″ content=″Microsoft FrontPage 3.0″〉

  〈title〉中國汽車服務專網汽車展場〈/title〉

  〈%if Request.QueryString(″idv″)〈〉″″ and Request.ServerVariables(″request_method″)=″GET″ then

  ′如果是其它頁面帶參數調用此頁面則為真

   end if

   if Request.ServerVariables(″request_method″)=″POST″ then

   ′如果是此頁面執行提交操作則為真

   if Request.Form(″cmdupdate″)=″更改″

   then

   ′如果是點擊cmdupdate按鈕則為真

   end if

   if Request.Form(″cmdnew″)=″新ID號″

   then

   ′如果是點擊cmdnew按鈕則為真

   end if

   if Request.Form(″cmdinsert″)=″添加″

   then

   ′如果是點擊cmdinsert按鈕則為真

   end if

  end if%〉

  〈%cn.close%〉

  〈/script〉

  〈/head〉

  〈body background=″images/backgrnd.jpg″〉

  〈form method=″post″ name=″frmedit″ LANGUAGE=″javascript″

   onsubmit=″return forminput_onsubmit()″〉

   〈div align=″center″〉〈center〉〈h5〉

   〈input type=″submit″ name=″cmdupdate″ value=″更改″〉

   〈input type=″submit″ name=″cmdnew″ value=″新ID號″〉

   〈input type=″submit″ name=″cmdinsert″ value=″添加″〉

   〈input type=″button″ name=″cmdback″ value=″返回″ onclick=″javascript:window.opener.focus()″〉

  〈/h5〉

  〈/center〉

  〈/div〉

  〈/form〉

  〈/body〉

  〈/html〉

  在Caredit.asp程式中,前三個按鈕為提交按鈕,而“返回”按鈕為普通按鈕。點擊前三個按鈕都對Caredit.asp頁面執行提交操作,只是執行的內容不同;“返回”按鈕則將焦點聚到開啟此頁面視窗的父視窗中。

  當ASP頁面中有功能相同的輸出部分時,可將相同的部分單獨製作成一個ASP頁面,在要調用的位置輸入〈!--#include file= ″ASP檔案名稱″--〉即可。

  對ASP頁面的調試可參照VIDV的說明設定,更快捷的方法是對需查看的變數直接用“〈%=”和“%〉”括起,當在伺服器端代碼程式中輸出變數時用“%〉〈%=”和“%〉〈%”括起。同理,當要答應報表時,對需輸出報表的位置編寫〈%=″需輸出的內容″%〉即可。

  當伺服器端代碼的SQL語句中含有變數時,分為以下兩種情況:

  ① 變數是字元、日期型時用′″&變數&″′表示,如:

  sql=″select name from student where name=′ ″&namev&″ ′ ″

  ② 變數是數字型、邏輯型時用″&變數&″表示,如:

  sql=″select name from student where score〉″&scorev&″ ″

  以上例子中變數都以字母V結尾,以示區別。



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.