只想知道 发表于 2015-1-16 23:22:17

ASP网页编程之创建一个相似YAHOO的导航条

当然了,现在国内CRM厂商的产品与其说是CRM,但从至少从我的角度分析上来看,充其量只是一个大型的进销存而已了,了解尚浅,不够胆详评,这里只提技术问题yahooThissamplewilldemonstratehowtoquicklybuildasimpleYahoo!stylenavigationbarthatdisplaysthepathsauserhastakentogettoagivendirectory,andalsodisplaysatableoflinkstothesub-directoriesofthecurrentdirectory.

ThefirstthingIliketodowhenbeginninganydatabasedrivenapplicationistodesignthedatastructure.Ofcourse,oncewegetintowritingthecode,manytimescolumnsortablesneedtobeaddedormodifiedfromtheinitialdesign,buthavingadataframeworkhelpstogiveussomefocusanddirection.

DatabaseLayout
IamusinganAccess2000databaseforthisexample.YoucandefinitelyportthistoanyRDBMSeasily;justfollowthesametablearchitecture.

LetsstartbycreatinganewAccessdatabase,andnameitBread.mdb.
CreateasingletableandnameittblParents.
OpenitupinDesignModeandaddthefollowingcolumns.


*Youcanskipbuildingallthisfromscratchbydownloadingthesourcefiles.

Bread.mdb
ColumnNameDataType
AIDAutoNumber(PrimaryKey)
DirNameText
ChildDirText
ParentDirText
ChildDirDescriptMemo
DirDescriptMemo

*IfdesigningforSQLServer,maketheAIDColumnanIdentityField,withanincrementof1andmakesureallownullsisoff.

Nextwewillwanttopopulateourtablewithdata,soletmeexplainthelogicofthearchitecture.

Startbyinsertingthedatafortherootdirectoryofyourwebserver.Thiswillbespecifiedbyinsertingaforwardslash/intotheDirNamecolumn.
NextaddthedirectorybelowtheroottotheChildDircolumn(makesureyouaddtheexactdirectorynameasitappearsontheserver)
Sincethisistherootdirectory,leavetheParentDircolumnblank.
FortheChildDirDescriptColumn,youwanttoenterwhateveryouwantthetexttoreadforthelinktotheChildDirdirectorythatyoujustentered.(i.e.,ifyouenteredmusicasaChildDirName,youmaywantthelinkthatpointstomusictoalsoreadMusic,soyouenterMusicintheChildDirDescriptcolumnforthisentry.IfyouwantittoreadModernMusic,enterthat)
FortheDirDescriptcolumn,enterthetextyouwanttoappeartodescribethecurrentdirectory,whichinthiscaseistherootfolder.IusedthewordHomeasthedescriptionsothatuserswillalwaysknowthatclickingonthislinkwillbringmebacktothebeginning.
Repeatthisprocessforeachsubdirectoryyouhavebelowyourwebroot.
Note:Makesuretocreatetheactualdirectorystructureonthewebserverifitdoesnotalreadyexist.
Yourdatashouldlooksimilartothis:




Afteryoucompletethisprocessmakesureyoualsomakeentriesinthedatabaseforthedirectoriesyoujustadded.InmycaseIaddedadirectoryMusic,sonowImustaddtheappropriateFieldsforMusic.SinceMusichasaparentdirectory(Root),wemustspecifyitbyaddingaforwardslashforParentDir.

PopulatethedataforMusicandanyotherSubDirectoriesyoulike.

Youmayrefertothescreenshotbelowformyexample.




*TheChildDircolumnsshouldcontainallthedirectoriesbelowtheRoot.

TheCode
Nowthatwehavesomevaliddata,letsstartbycreatingacoupleoffunctions.Wewillhousethesefunctionsinanincludefile,namedfolderFunctions.asp.Thefirstfunctionwewantisafunctiontoreturnthecurrentphysicaldirectoryofthewebserver.Wewillusethisfunctionwhenwedoadatabaselookuptobuildtheappropriatelinksandpathhistory.InamedthisfunctionGetThisPath.

Firstthingourfunctionneedstodoisgetthecurrentfullpathfromtheserver.WewillusethePath_InfomethodoftheServerVariablescollectiontolookitup.

Sinceweonlywantthecurrentdirectoryname,wewillsplitthestringreturnedfromPath_Infoattheforwardslash,whichwillcreateanarraycontainingallthedirectoriesabovethecurrentdirectory.Thenwewillneedtoloopthrutheentirearraytopullonlythedataweneed(thecurrentdirectory).Wewillaccomplishthisbysettingourlooptoexitatthenexttothelastentryinthearray(Theverylastentrywouldbethepagenameandwedontwantthat).Thewaywedothisistotellthelooptoexecuteasmanytimesasvaluesthearrayholdsminusone.WegetthatinformationbyaskingthearrayforitsupperBounds.

Thenwewillsetthefunctionsreturnvaluetothelastentryinourloopbyoverwritingthereturnvalueineachloop,whichwillbethecurrentdirectory.However,ifthearrayisempty,itmeansweareattherootoftheserverandweneedtosetthereturnvalue</p>ASP脚本是采用明文(plaintext)方式来编写的。

admin 发表于 2015-1-20 09:43:23

下面简单介绍一下我学习ASP的方法,希望对想学习ASP的朋友有所帮助...

精灵巫婆 发表于 2015-1-26 13:15:53

我认为比较好的方法是找一些比较经典的例子,每个例子比较集中一种编程思想而设计的。

灵魂腐蚀 发表于 2015-2-2 11:11:31

Session:这个存储跟客户端会话过程的数据,默认20分钟失效

再现理想 发表于 2015-2-3 14:08:58

如何学好ASP,以前也有人问过,把回答给你转过来看看能否对你有帮助:

蒙在股里 发表于 2015-2-9 02:55:05

交流是必要的,不管是生活还是学习我们都要试着去交流,通过交流我们可以学到很多我们自己本身所没有的知识,可以分享别人的经验甚至经历。

若相依 发表于 2015-2-26 19:32:01

没有坚实的理论做基础,那么我们连踏入社会第一步的资本都没有,特别对于计算机专业的学生学好专业知识是置关重要的。在这里我侧重讲一下如何学习ASP,从平时的学习过程中。

深爱那片海 发表于 2015-3-8 16:47:13

我可以结合自己的经验大致给你说一说,希望对你有所帮助,少走些弯路。

只想知道 发表于 2015-3-16 06:24:54

如何更好的使自己的东西看上去很不错等等。其实这些都不是问题的实质,我们可以在实践中不断提升自己,不断充实自己。

小魔女 发表于 2015-3-22 20:52:27

ASP的语言不仅仅只是命令格式差不多,而是包含在<%%>之内的命令完全就是VB语法。虽然ASP也是做为单独的一个技术来提出的,但他就是完全继承了VB所有的功能。
页: [1]
查看完整版本: ASP网页编程之创建一个相似YAHOO的导航条