濮阳杆衣贸易有限公司

主頁 > 知識庫 > ASP常用的幾個功能模塊

ASP常用的幾個功能模塊

熱門標(biāo)簽:縣域地圖標(biāo)注打印店 鳳臺百度地圖標(biāo)注店 修改地圖標(biāo)注 金昌電話機(jī)器人價格 怎么在地圖標(biāo)注自己 個人可以辦理400電話么 武夷山旅游地圖標(biāo)注 外呼系統(tǒng)API接口 萊西電子地圖標(biāo)注
1,經(jīng)常寫些系統(tǒng),那么一般都是從登錄程序開始,每接一個系統(tǒng)就寫一次登錄,好麻煩。

干脆直接做個登錄驗(yàn)證函數(shù)吧,對我來說,大都情況可以勝任了:)
[code]
%
Function chk_regist(requestname,requestpwd,tablename,namefield,pwdfield,reurl)dim cn_name,cn_pwdcn_name=trim(request.form(""requestname""))cn_pwd=trim(request.form(""requestpwd""))if cn_name="" or cn_pwd="" thenresponse.Write("script language=javascript>alert(""請將帳號密碼填寫完整,謝謝合作。"");history.go(-1)/script>")end ifSet rs = Server.CreateObject ("ADODB.Recordset")sql = "Select * from "tablename" where "namefield"=''"cn_name"''"rs.open sql,conn,1,1if rs.eof thenresponse.Write("script language=javascript>alert(""沒有該會員ID,請確認(rèn)有沒有被申請。"");history.go(-1)/script>")elseif rs(""pwdfield"")=cn_pwd then session("cn_name")=rs(""namefield"")response.Redirect(reurl)elseresponse.Write("script language=javascript>alert(""提醒,您的帳號和密碼是不吻合。注意數(shù)字和大小寫。"");history.go(-1)/script>")end ifend ifrs.close Set rs = NothingEnd Function%>
[code]
參數(shù)說明:
chk_regist(requestname,requestpwd,tablename,namefield,pwdfield,reurl)

requestname 為接受HTML頁中輸入名稱的INPUT控件名
requestpwd 為接受HTML頁中輸入密碼的INPUT控件名
tablename 為數(shù)據(jù)庫中保存注冊信息的表名
namefield 為該信息表中存放用戶名稱的字段名
pwdfield 為該信息表中存放用戶密碼的字段名
reurl 為登錄正確后跳轉(zhuǎn)的頁

引用示例如下:
%call chk_regist("b_name","b_pwd","cn_admin","cn_name","cn_pwd","admin.asp")%>

2,經(jīng)常有可能對某個事物進(jìn)行當(dāng)前狀態(tài)的判斷,一般即做一字段(數(shù)值類型,默認(rèn)值為0)
通過對該字段值的修改達(dá)到狀態(tài)切換的效果。那么,我又做了個函數(shù),讓自己輕松輕松。
%Function pvouch(tablename,fildname,autoidname,indexid)dim fildvalueSet rs = Server.CreateObject ("ADODB.Recordset")sql = "Select * from "tablename" where "autoidname"="indexidrs.Open sql,conn,2,3fildvalue=rs(""fildname"")if fildvalue=0 thenfildvalue=1elsefildvalue=0end ifrs(""fildname"")=fildvaluers.updaters.close Set rs = NothingEnd Function%>

參數(shù)說明:
pvouch(tablename,fildname,autoidname,indexid)

tablename 該事物所在數(shù)據(jù)庫中的表名
fildname 該事物用以表明狀態(tài)的字段名(字段類型是數(shù)值型)
autoidname 在該表中的自動編號名
indexid 用以修改狀態(tài)的對應(yīng)自動編號的值

引用示例如下:
%dowhat=request.QueryString("dowhat")p_id=cint(request.QueryString("p_id"))if dowhat="tj" and p_id>"" thencall pvouch("cn_products","p_vouch","p_id",p_id)end if%>%if rs("p_vouch")=0 then%>>推薦%else%>>取消推薦%end if%>

3,為很多中小企業(yè)寫站點(diǎn),一般產(chǎn)品展示是個大項(xiàng)目,那么做成的頁面也就不同。
要不就是橫排來幾個,要不就是豎排來幾個,甚至全站要翻來覆去的搞個好幾次,麻煩也很累。
索性寫個函數(shù)能緩解一下,于是就成了下面
%function showpros(tablename,topnum,fildname,loopnum,typenum)Set rs = Server.CreateObject ("ADODB.Recordset")sql = "Select top "topnum" * from "tablenamers.Open sql,conn,1,1if rs.eof and rs.bof thenresponse.Write("暫時無該記錄")elseresponse.Write("")for i=1 to rs.recordcountif (i mod loopnum=1) thenresponse.write" "end ifselect case typenumcase "1"response.Write(" ")response.Write(rs(""fildname""))response.Write(" ")response.Write("方式1之"i"記錄")''此處的“方式1”可以替換顯示為其余字段的值response.Write(" ")''如果字段比較多,繼續(xù)添加新個表格行來顯示response.Write("  ")case "2"response.Write(" ")response.Write(rs(""fildname""))response.Write(" ")response.Write(" ")response.Write("方式2之"i"記錄")response.Write(" ")response.Write("  ")end selectif (i mod loopnum=0) thenresponse.write" "end ifrs.movenextnextresponse.Write(" ")end ifrs.close Set rs = Nothingend function%>

參數(shù)說明:showpros(tablename,topnum,fildname,loopnum,typenum)
whichpro為選擇何類型的產(chǎn)品種類
topnum表示提取多少條記錄
fildname表示調(diào)試顯示的字段,具體應(yīng)用的時候可以省去該參數(shù),在函數(shù)內(nèi)部直接使用
loopnum表示顯示的循環(huán)每行的記錄條數(shù)
typenum表示循環(huán)顯示的方法:目前分了兩類,橫向并列、縱向并列顯示同一數(shù)據(jù)記錄行的不同記錄

引用示例如下:
%if request.form("submit")>"" thentopnum=request.form("topnum")loopnum=request.form("loopnum")typenum=request.form("typenum")elsetopnum=8loopnum=2typenum=1end if%>%call showpros("cn_products",topnum,"p_name",loopnum,typenum)%>

標(biāo)簽:邢臺 清遠(yuǎn) 赤峰 上海 涼山 通遼 南京 楚雄

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ASP常用的幾個功能模塊》,本文關(guān)鍵詞  ASP,常用的,常,用的,幾個,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ASP常用的幾個功能模塊》相關(guān)的同類信息!
  • 本頁收集關(guān)于ASP常用的幾個功能模塊的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    北京市| 湘潭县| 金昌市| 茶陵县| 新竹县| 敖汉旗| 南陵县| 游戏| 武威市| 桃园县| 南华县| 海丰县| 盐城市| 石景山区| 外汇| 淄博市| 普兰县| 广德县| 西盟| 余干县| 安龙县| 卓尼县| 安达市| 浮梁县| 龙岩市| 永安市| 十堰市| 新余市| 朔州市| 张家口市| 阜平县| 抚宁县| 绵竹市| 淄博市| 乌兰浩特市| 上饶市| 东乡族自治县| 黎平县| 阿巴嘎旗| 大悟县| 道孚县|