ASP教程之制造一个复杂的告白体系
ASP最大的缺点在于网络的安全性和可靠性,企业将经营数据放在开放的平台上,最大的担忧就是如何保证这些数据不被其他人破坏。告白byManoharKamathAugust9,1999
Creatingaadvertisementrotatorpageiseasy-ASPcomeswithanAdrotatorcomponentthatseasytouse.
Thecomponent,calledAdRotator,isinstalledwhenyouinstallASP.ThecomponenthasbeenapartofASP
installationsincethefirstversionofASP.
Thereare3partstotheadrotatorsystem:
Adrotatorlogicpage
Adimagesdatefile
Redirectionpage
Adrotatorlogicpage
Createafilesayads.inc,anincludefilethatcanbeincludedonanyASPpageonyoursite.Thisfile
willactually"create"theimagelinksontheASPpages.Thepagemakesuseofthefileinitem2,thead
imagesdatafiletochoosetheimagefromthelistofimages.
Thecodeisasshownbelow.IcreatedafunctiongetAd()sothatthisfunctioncanbecalledwithinany
ASPpagewhereyouwantthebannerstoshowup.Theadvantageofputtingthelogicinthefunctionis
obvious-reuseabilityofcode.
<SCRIPTLANGUAGE=VBScriptRUNAT=SERVER>
FunctiongetAd()
DimloAd
CreateaninstanceoftheAdrotatorcomponent
SetloAd=Server.CreateObject("MSWC.AdRotator")
Setthetargetframe,ifany.Thisistheframethewheread
URLwillopenup.IftheHTMLpagedoesnotfindthetargetname
theURLwillbeopenedinanewwindow
loAd.TargetFrame="TARGET=new"
Getarandomavertisementfromthetextfile
Thisfileisinthe/adfolder
getAd=loAd.GetAdvertisement("/ad/adrotator.txt")
EndFunction
</SCRIPT>
Adimagesdatafile
createtheadinformationfile,sayadrotator.txt.Thisfilehastwoparts
Generalinformationforalltheimages-thisinformationisappliedtoallimagesthatarerotated.This
sectioncontains4parts
REDIRECT-thepagethatwillhandletheredirects.youcanspecifyaabsoluteorarelativeURLforthis
page
WIDTH-Widthoftheimages.Ifnotspecified,defaultsto60
HEIGHT-Heightofimages.Ifnotspecified,defaultsto440
BORDERoftheimage.Ifnotspecified,defaultsto1
Individualimageinformation.Thissectionisseparatedfromthefirstbyasingle"*"onaseparateline
asshowninthecodebelow.Thissectionhasfourparts
Imagesource-eitherabsolute,relativeoraURLlikehttp://...
RedirectURL-theURLtobesentwhentheuserclicksontheimage
Alternatetext-Abriefdescriptionoftheadthatappearsintextbrowsers,orwhentheimagesare
turnedoff
Adweight-anumberbetween0and4,294,967,295thatdeterminesthefrequencyofthataddisplay.A
weightof0meanstheadwillneverbedisplayed.Higherthenumber,morefrequentthedisplayis.
E.g.Intheexamplebelow,theweightsoftwoimagesare2and3.So,thesecondimageis3timesmore
likelytoappearforevery2appearanceoffirst.
Assumingtheimagesareinthe/imagesdirectory,asampleadrotator.txtfileisshownbelow.The*
separatesthegeneraldatafromtheimageinfo.Withintheimagesinfo,leaveablanklinebetweeneach
imagedata.
REDIRECTadredir.asp
WIDTH468
HEIGHT60
BORDER0
*
/images/fp2000.gif
http://www.microsoft.com/frontpage
MicrosoftFrontPage2000
2
/images/office2000.gif
http://www.microsoft.com/office
Office2000
3
Redirectionpage
Theredirectionpage,receivesinitsquerystring,avariablenamedURLthatcontainstheURLtoredirect
to,andanothervariableIMAGEthatcontainstheimageURLoftheadimage.TheIMAGEvariableismorefor
statisticalpurposes,tokeepcountofwhatimageappearedwhenandhowmanytimesetc.So,ifyouwereto
keepcountofwhatimageswereclicked,youwouldlogthisintoadatabase(therearebetterways,but
justtryingtoillustratewhythevariableispassed).
Asimpleredirectpage,adredir.asp,isasfollows.ItessentiallyretrievestheURLfromthequerystring
anddoesaResponse.Redirecttoit.
<%@language=VBScript%>
<%
Settheresponsebufferon
Response.Buffer=True
DimlsURL
ObtaintheURLfromthequerystring
lsURL=Request.QueryString("URL")
CleartheresponseandredirecttoURL
Response.Clear()
Response.Redirect(lsURL)
%>
Usingthesystem
Includethefileads.inconanyA</p>我想详细了解ASP整站代码与PSP整站代码有什么优缺点,那个更好,更安全,更用容易维护,和管理。。。 我就感觉到ASP和一些常用的数据库编程以及软件工程方面的思想是非常重要的。我现在也在尝试自己做网页,这其中就用到了ASP,我想它的作用是可想而知的。 你可以通过继承已有的对象最大限度保护你以前的投资。并且C#和C++、Java一样提供了完善的调试/纠错体系。 我认为比较好的方法是找一些比较经典的例子,每个例子比较集中一种编程思想而设计的。 跟学别的语言一样,先掌握变量,流程控制语句(就是ifwhileselect)等,函数/过程,数组 最近在学asp,不要问我为什么不直接学.net,因为公司网站是asp做的所以有这个需要,卖了本书asp入门到精通,对里面的六大内置对象老是记不住,还有很多属性和方法看的头晕。 运用ASP可将VBscript、javascript等脚本语言嵌入到HTML中,便可快速完成网站的应用程序,无需编译,可在服务器端直接执行。容易编写,使用普通的文本编辑器编写,如记事本就可以完成。由脚本在服务器上而不是客户端运行,ASP所使用的脚本语言都在服务端上运行。 掌握asp的特性而且一定要知道为什么。 代码逻辑混乱,难于管理:由于ASP是脚本语言混合html编程,所以你很难看清代码的逻辑关系,并且随着程序的复杂性增加,使得代码的管理十分困难,甚至超出一个程序员所能达到的管理能力,从而造成出错或这样那样的问题。 从事这个行业,那么你可以学ASP语言,简单快速上手,熟练dreamweav排版,写asp代码,熟练photoshop处理图片,打好基础就行了 从事这个行业,那么你可以学ASP语言,简单快速上手,熟练dreamweav排版,写asp代码,熟练photoshop处理图片,打好基础就行了
页:
[1]