資源描述:
《asp常用(asp commonly used)》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、asp常用(ASPcommonlyused)20veryusefulexamplesofASPprogramming1.howtouseAsptodeterminethevirtualphysicalpathofyourwebsiteAnswer:usingtheMappathmethod"Palign="center"font""size="4"face="Arial">>bThePhysicalpathtothisvirtualwebsiteis:>/font"Fontcolor="#FF0000"size="6"face="Arial"><%=Server.Map
2、Path("")%>>/p2.myusersknowhowtouseabrowser?Answer:usingthetheRequestobjectmethodStrBrowser=Request.ServerVariables("HTTP_USER_AGENT")IfInstr(strBrowser,"MSIE")<<0ThenResponse.redirect("ForMSIEOnly.htm")ElseResponse.redirect("ForAll.htm")EndIfHowtocalculatethedailyaverageof3.repeatedv
3、isitsAnswer:solution<%startdate=DateDiff("d","Now","01/01/1990")Ifstrdate<0thenstartdate=startdate*-1Avgvpd=Int((usercnt)/startdate)%>Displayresults<%response.write(avgvpd)%>Thatisit.thispagehavebeenviewedsinceNovember1019984.howtodisplayrandomimages<%dimP,PPIC,dpicPpic=12RandomizeP=Int((ppi
4、c*rnd)+1)Dpic="graphix/randompics/"&p&".Gif""%>display<><%=dpic%>>>5.howtogobacktothepreviouspageAnswer:"ahref="%=request.serverVariables"("Http_REFERER")%>">preivouspage<>/aOrusepictureslike:<%=request.serverVariables(HTTP_REFERER)>%>>6.howtodeterminet
5、heotherparty'sIPaddressAnswer:%=Request.serverVariables("REMOTE_ADDR")%>7.howtolinktoapictureAnswer:<%@Languages=vbscript%><%response.expires=0Strimagename="graphix/errors/erroriamge.gif""Response.redirect(strimagename)%>8.forcedinputpassworddialogboxAnswer:putthissentenceatthebeginningofthe
6、page<%response.status="401notAuthorized"Response.end%>9.howtopassvariablesfromonepagetoanotherpageAnswer:useHIDDENtypetopassvariables<%formmethod="post"action="mynextpage.asp"><%foreachiteminrequest.form%>type="HIDDEN"""Value="%=server.HTMLEncode(Request.form(item))%>><
7、%next%>10.whyIwithintheASPprogramusingthemsgboxprogram,saidthereisnopermissionerrorAnswer:becauseASPisaserverrunningontheserver,ifyoucandisplayadialogbox,thenyouhadtowaitforsomeonetodetermineafteryourprogramtocontinue,butnooneguardingthegene