ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/index.asp Page 1


Table of Contents

/learn Table of Contents

ASP Quick Lessons - Table of Contents (/learn/index.asp) - Page 1
Credits (/learn/credits.asp) - Page 2
Core Ideas (/learn/core.asp) - Page 3
        What is ASP? Obtaining The Software (/learn/whatis.asp) - Page 4
        AspInstall listserver (/learn/aspinstall.asp) - Page 5
        Simple ASP Page, Server Scripting (/learn/whatisexample.asp) - Page 6
        MS Online Documentation (/learn/docs.asp) - Page 7
        Response: Basics (/learn/res.asp) - Page 8
        Response: Buffers, Redirect (/learn/res2.asp) - Page 9
        Response: Redirection (/learn/res3.asp) - Page 10
        Response: Quotes & Special Characters (/learn/res4.asp) - Page 11
        Response: Encoding URLs, HTML (/learn/res5.asp) - Page 12
        Include: Basics (/learn/inc.asp) - Page 13
        Include: Dynamic FileName (/learn/includedynamic.asp) - Page 14
        Includes: Other Sites, Dynamic FileNames (/learn/includeasphttp.asp) - Page 15
        Include/Redirects: New Win2k Commands (/learn/incwin2k.asp) - Page 16
        Include: Books Sample Exercise (/learn/booksample.asp) - Page 17
        More Book Sample Exercises (/learn/booksample2.asp) - Page 18
        Format: Numbers #1 (/learn/formatnumbers.asp) - Page 19
        Format: Numbers #2 (/learn/formatnumbers2.asp) - Page 20
        Format: Dates #1 (/learn/formatdates.asp) - Page 21
        Date/Time on ASP Pages by Tony Arguelles (/learn/datetime.asp) - Page 22
        Loops: DO WHILE/UNTIL #1 (/learn/DoLoop.asp) - Page 23
        Loops: Timeouts #2 (/learn/DoLoop2.asp) - Page 24
        Loops: Intercepting Timeouts #3 (/learn/DoLoop3.asp) - Page 25
        Server Variables: Popular Ones (/learn/server.asp) - Page 26
        Server Variables: Domain/Host Name (/learn/server2.asp) - Page 27
        Server Variables: Displaying All (/learn/serverall.asp) - Page 28
        Random Content/Rotating Info (/learn/randomadvice.asp) - Page 29
        Browscap: Basics (/learn/bc.asp) - Page 30
        Browscap: Intricate Details (/learn/bcdetails.asp) - Page 31
        Listserver for Browser Problems (/learn/aspbrowserheck.asp) - Page 32
State Management (/learn/statemanagement.asp) - Page 33
        State Management Introduction (/learn/stateintro.asp) - Page 34
        What are ASP Sessions? (/learn/sessionswhat.asp) - Page 35
        Application Data (/learn/sessionsapps.asp) - Page 36
        Application Data: Worlds Fastest ListBox (/learn/speedappdata.asp) - Page 37
        XML, Database Caches - Fast Retrieval (/learn/xmlfastlist.asp) - Page 38
        Say No To Databases w/Sessions or Application scope (/learn/nodbsession.asp) - Page 39
        Session Overview & Myths (/learn/sessionoverview.asp) - Page 40
        Sessions: Global.asa and Scalability (/learn/globalproblems.asp) - Page 41
        Sessions: Global.asa Events (/learn/global.asp) - Page 42
        Global.asa, Sessions, Custom Stats Resources (/learn/statemore.asp) - Page 43
        State Methods: Pros and Cons (/learn/stateproscons.asp) - Page 44
        Pass Data w/Hidden Fields (/learn/hidden.asp) - Page 45
        Pass Data w/Cookies (/learn/cookies.asp) - Page 46
        Pass Data w/Session Vars (/learn/statesessions.asp) - Page 47
        Pass Data w/ID tied to database (/learn/statedb.asp) - Page 48
        [aspStateManagement] Listserver (/learn/aspstatemanagement.asp) - Page 49
Forms/Decisions (/learn/Form.asp) - Page 50
        Forms: Introduction (/learn/formintro.asp) - Page 51
        Forms: Text Box (/learn/formtextbox.asp) - Page 52
        Forms: Text Area (/learn/formtextarea.asp) - Page 53
        Forms: Check Box (/learn/formcheckbox.asp) - Page 54
        Forms: Radio Buttons (/learn/formradio.asp) - Page 55
        Forms: List Box (/learn/formlistbox.asp) - Page 56
        Forms: CASE syntax #1 (/learn/case.asp) - Page 57
        Forms: CASE syntax #2 (/learn/case2.asp) - Page 58
        Forms: IF syntax #1 (/learn/if.asp) - Page 59
        Forms: IF syntax #2 (/learn/if2.asp) - Page 60
        Forms: IF syntax #3 (/learn/if3.asp) - Page 61
        Forms: IF syntax #4 (/learn/if4.asp) - Page 62
        Forms: For Each Iteration (/learn/formforeach.asp) - Page 63
        Form - Submit To Self' (/learn/formsubmitself.asp) - Page 64
        Form - Change Action on Fly (/learn/formactionchange.asp) - Page 65
Databases (/learn/database.asp) - Page 66
        Displaying Table w/Simple Code (/learn/dbsimple.asp) - Page 67
        List Box Displayed Generically (/learn/dblist.asp) - Page 68
        Database to ListBox Online Resources (/learn/dblistmore.asp) - Page 69
        DSNLess Connections (/learn/dbopen.asp) - Page 70
        DSN Setup #1 by Rob Martinson (/learn/dsn1.asp) - Page 71
        DSN Setup #2 by Rob Martinson (/learn/dsn2.asp) - Page 72
        DSN Setup #3 by Rob Martinson (/learn/dsn3.asp) - Page 73
        DSN Setup #4 by Rob Martinson (/learn/dsn4.asp) - Page 74
        DSN Setup #5 by Rob Martinson (/learn/dsn5.asp) - Page 75
        DSN Setup #6 by Rob Martinson (/learn/dsn6.asp) - Page 76
        Full Cycle #1 Show/Edit/Update (/learn/dbfull1.asp) - Page 77
        Full Cycle #2 Show/Edit/Update (/learn/dbfull2.asp) - Page 78
        Full Cycle #3 Show/Edit/Update (/learn/dbfull3.asp) - Page 79
        SQL Mistakes Everyone Makes (/learn/dbtroubleshoot2.asp) - Page 80
        DB: Table Displayed Generically (/learn/dbtable.asp) - Page 81
        Getstring to display database table (/learn/dbtablegetstring.asp) - Page 82
        Getrows to display database table (/learn/dbtablegetrows.asp) - Page 83
        GetRows w/no Numbers (/learn/dbtablegetrowsnonum.asp) - Page 84
        Disconnected Recordsets, Display Table (/learn/dbtabledisconnected.asp) - Page 85
        DB: More ways To Display Tables (/learn/dbtablemore.asp) - Page 86
        DB: Generic DB by Eli Robillard (/learn/genericdb.asp) - Page 87
        Generic DB Listserver (/learn/aspgenericdb.asp) - Page 88
        DB: Converting a DB to a Comma-Delimited file (/learn/dbconvert.asp) - Page 89
        DB: Deleting a Record w/SQL (/learn/dbSQLdelete.asp) - Page 90
        DB: Access Scalability (/learn/accesstest.asp) - Page 91
        ADO: Paging Records (/learn/dbtablepaged.asp) - Page 92
        ADO: Limiting Number of Records (/learn/dbmaxrecs.asp) - Page 93
        ADO: Count Records in Query (/learn/dbcount.asp) - Page 94
        ADO: Cursor Types by Phil Paxton (/learn/adocursortypes.asp) - Page 95
        ADO: Input Form (/learn/dbnewrec.asp) - Page 96
        ADO: Input Form, added w/SQL (/learn/dbnewSQL.asp) - Page 97
        ADO: Input Form, Added w/ADO .addnew (/learn/dbnewADO.asp) - Page 98
        ADO: Tables within Databases (/learn/dbtablelists.asp) - Page 99
        ADO: Schemas to access table lists (/learn/dbschemas.asp) - Page 100
        ADO: Schemas to access All Data (/learn/dbschemasall.asp) - Page 101
        ADO: Show Table,1 param (/learn/db1parm.asp) - Page 102
        ADO: Update/edit Record (/learn/dbupdate.asp) - Page 103
        DB: Troubleshooting Part 1 (/learn/dbtroubles.asp) - Page 104
        DB: Troubleshooting Part 2 (/learn/dbtroubles2.asp) - Page 105
SQL Basics, Searching Databases (/learn/SQL.asp) - Page 106
        SQL Troubles (/learn/SQLtroubles.asp) - Page 107
        SQL: Example Tables (/learn/SQLexamples.asp) - Page 108
        SQL: Where Clause Basics (/learn/SQLwhere.asp) - Page 109
        SQL: Where Clause Examples (/learn/SQLwhere2.asp) - Page 110
        SQL: Search Forms #1 (/learn/SQLwhereform1.asp) - Page 111
        SQL: Search Forms #2 (/learn/SQLwhereform2.asp) - Page 112
        SQL: Search Forms #3 (/learn/SQLwhereform3.asp) - Page 113
        SQL: Search AND/OR Operators (/learn/SQLandor.asp) - Page 114
        SQL: Search AND/OR Examples (/learn/SQLandor2.asp) - Page 115
        SQL: COUNT, GROUPBY (/learn/SQLcount.asp) - Page 116
        SQL: SUM, MIN, AVE, MAX (/learn/SQLaggregate.asp) - Page 117
        SQL Joins by Aaron Alexander (/learn/dbjoin.asp) - Page 118
RSFAST: Lightning Fast Database Library (/learn/rsfast.asp) - Page 119
        RSFast Library Introduction (/learn/rsfast-intro.asp) - Page 120
        Table Display Fast (/learn/rsfast-table.asp) - Page 121
        Table Display Fast + Caching (/learn/rsfast-table-cached.asp) - Page 122
        Listbox Display Fast (/learn/rsfast-lists.asp) - Page 123
        Listbox Display Fast + Caching (/learn/rsfast-lists-cached.asp) - Page 124
        Templates for any look Fast (/learn/rsfast-templates.asp) - Page 125
        Debug Info helps troubleshoot (/learn/rsfast-lists-debug.asp) - Page 126
        Library Source Code (/learn/rsfast-lib.asp) - Page 127
        caching Method Explained (/learn/rsfast-cache.asp) - Page 128
        New Features for Future Versions (/learn/rsfast-newfeatures.asp) - Page 129
Editors Used With ASP (/learn/editors.asp) - Page 130
        ASPExpress: HOT ASP Editor (/learn/aspexpress.asp) - Page 131
        Visual Interdev + Admunsen Resources (/learn/admunsen.asp) - Page 132
        Visual Interdev Listserver (/learn/aspvisualinterdev.asp) - Page 133
        Homesite: HTML editor (/learn/homesite.asp) - Page 134
        DreamWeaver: HTML and Script Editor (/learn/dreamweaver.asp) - Page 135
Essential Commercial Components (/learn/components.asp) - Page 136
        ASPDB: Displaying Data (/learn/aspdb1.asp) - Page 137
        ASPDB: Editing, Adding Data (/learn/aspdb2.asp) - Page 138
        BrowserHawk: Determing Browser Type (/learn/bhbrowtype.asp) - Page 139
        AOL detection w/BrowserHawk (/learn/bhaol.asp) - Page 140
        MS-Wallet w/BrowserHawk (/learn/bhwallet.asp) - Page 141
        Reverse DNS lookups w/BrowserHawk (/learn/bhresolveip.asp) - Page 142
        BrowserHawk - Frame support (/learn/bhframes.asp) - Page 143
        Flash Detection w/BrowserHawk (/learn/bhflash.asp) - Page 144
        ServerObject Mail: Simple Example (/learn/serverobjectsmail.asp) - Page 145
        ServerObject: Mailing Form w/ASPMail (/learn/formsendmail.asp) - Page 146
        3rd Party Mail, CDO/CDONTS Listserver (/learn/aspmail.asp) - Page 147
        SA: File Upload, Simple Example (/learn/uploadsimple.asp) - Page 148
        SA: File Upload, Multi-part form (/learn/uploadmultipart.asp) - Page 149
        SA: File Upload, Limit Size (/learn/uploadlimitsize.asp) - Page 150
        SA: File Upload, Many Files (/learn/uploadmanyfiles.asp) - Page 151
        Upload/Soft-Artisans Listserver (/learn/aspsoftartisans.asp) - Page 152
        Perf Counters on ASP page (/learn/perfcounters.asp) - Page 153
Authentication & Security (/learn/authenticate.asp) - Page 154
        Authenticate: Overview by Kevin Flick (/learn/authenticateoverview.asp) - Page 155
        Authenticate: Comparison by Kevin Flick (/learn/authenticatecomparisons.asp) - Page 156
        Authenticate: NT Challenge/Response by Kevin Flick (/learn/authenticatentcr.asp) - Page 157
        Authenticate: Basic Authentication by Kevin Flick (/learn/authenticatebasic.asp) - Page 158
        Authenticate: Cookies by Kevin Flick (/learn/authenticatecookies.asp) - Page 159
        Authenticate: Certificates by Kevin Flick (/learn/authenticatecertificate.asp) - Page 160
        Authenticate: Build Your Own by Kevin Flick (/learn/authenticatebuild.asp) - Page 161
        Authenticate: Protect Pages via Login #1 (/learn/security.asp) - Page 162
        Authenticate: Protect Pages via Login #2 (/learn/security2.asp) - Page 163
        Authenticate: 3rd Party by Kevin Flick (/learn/authenticate3rdparty.asp) - Page 164
        Authentix Flicks Support Listserver (/learn/aspflicks.asp) - Page 165
Troubleshooting, Error Trapping (/learn/troubles.asp) - Page 166
        Errors: Basics (/learn/errors1.asp) - Page 167
        Errors: More Ways To Trap (/learn/errors2.asp) - Page 168
        Errors: Resources Online (/learn/errormore.asp) - Page 169
        Errors: Trapping EVERY Error (/learn/dbtablewitherrortrap.asp) - Page 170
        Debug variables Easy Way (/learn/debug1.asp) - Page 171
        Errors: DB Error Information Trapping (/learn/dbtroubleshoot.asp) - Page 172
        DBFAQ: Operation must use Updatable Query (/learn/FAQdbUpdate.asp) - Page 173
        DBFAQ: User Entered ' in field (/learn/FAQdbSinglequote.asp) - Page 174
        DBFAQ: LIKE operator * not working (/learn/FAQdbLIKE.asp) - Page 175
        DBFAQ: retrieving MEMO/BLOBs generates error (/learn/FAQdbMEMO.asp) - Page 176
        DBFAQ: Syntax Error in SQL Statement (/learn/FAQdbSQLSyntax.asp) - Page 177
        SQL Debugging Made Easy (/learn/debug2.asp) - Page 178
        Errors: Trapping Open Connections (/learn/dbtroubleshootopen.asp) - Page 179
        Troubleshoot: Getting Help from Lists! (/learn/asptroubles.asp) - Page 180
        Troubleshoot: Worldwide (/learn/asptroubles2.asp) - Page 181
        Troubleshoot: Specialized (/learn/asptroubles3.asp) - Page 182
        Troubleshoot: Version of ASP Sofware (/learn/versioncheck.asp) - Page 183
        Troubleshoot: Registered Components (/learn/componentchecker.asp) - Page 184
        Troubleshoot: DB Drivers by Christophe Wille (/learn/connectioninfo.asp) - Page 185
        PWS: Personal Web Server Introduction (/learn/PWS.asp) - Page 186
Code w/all ASP Features. Quality, Re-usable Code (/learn/qualitycode.asp) - Page 187
        Strings: Core Functions (/learn/strings.asp) - Page 188
        Strings: SPLIT Function (/learn/stringsplit.asp) - Page 189
        Strings: REPLACE Function (/learn/stringreplace.asp) - Page 190
        Strings: JOIN Function (/learn/stringjoin.asp) - Page 191
        Arrays: Basics (/learn/arrays.asp) - Page 192
        Arrays: Variable Size (/learn/arrays2.asp) - Page 193
        Arrays: Best Way To Load (/learn/arrays3.asp) - Page 194
        Arrays: Resources Online (/learn/arraysmore.asp) - Page 195
        Dictionary Objects (/learn/dictionary.asp) - Page 196
        Getrows Ultimate! (/learn/getrowsultimate.asp) - Page 197
        Subroutine: Working with Dates #1 (/learn/subdates.asp) - Page 198
        Subroutine: Working with Dates #2 (/learn/subdates2.asp) - Page 199
        Subroutine: Query2Table (/learn/subdbtable.asp) - Page 200
        Subroutine: Query2List (/learn/subdblist.asp) - Page 201
        Subroutine: Highly Reusable (/learn/subreusable.asp) - Page 202
        Subroutines w/Dictionary Objects (/learn/subdictionary.asp) - Page 203
        Getrows Ultimate! (/learn/getrowsultimate.asp) - Page 204
        Subroutine: List Box w/optional params (/learn/subDBlistbest.asp) - Page 205
        Subroutine: Abstract HTML by Phil Paxton (/learn/libhtml.asp) - Page 206
        Function: Working Days (/learn/functionworkingdays.asp) - Page 207
        New Features in VBScript version5 (/learn/vbs5.asp) - Page 208
        Text Files: Reading Them off Server (/learn/txtread.asp) - Page 209
        Text Files: Writing Them on Server (/learn/txtwrite.asp) - Page 210
        Text Files: Meyers-Briggs parsing #1 (/learn/mb1.asp) - Page 211
        Text Files: Meyers-Briggs parsing #2 (/learn/mb2.asp) - Page 212
        Text Files: Meyers-Briggs parsing #3 (/learn/mb3.asp) - Page 213
        XML/XLST Myers-Briggs example (/learn/xmlmb.asp) - Page 214
        Content Linker: Prev/Next Page (/learn/cl.asp) - Page 215
        Content Linker: Table of Contents (/learn/cl2.asp) - Page 216
        Content Linker: Listbox of contents (/learn/cl3.asp) - Page 217
        Content Linker Library (/learn/contentlinker.asp) - Page 218
        File Objects: Read Directory (/learn/fileobjects.asp) - Page 219
        File Objects: Display Directory as Links/Graphics (/learn/fileobjects2.asp) - Page 220
        File Objects: Read Disk Drive by Steven Harper (/learn/fileobjects3.asp) - Page 221
        File Objects: Show Dir List by Tim Foster (/learn/fileobjects4.asp) - Page 222
        Graphic Size Detector (/learn/graphicdetect.asp) - Page 223
High Speed Code, Scalable Code... (/learn/speedscale.asp) - Page 224
        Time Tasks with Millisecond Accuracy (/learn/speedtimer.asp) - Page 225
        Speed: Coding Tips (/learn/speedtips.asp) - Page 226
        Why Buffer? (/learn/whybuffer.asp) - Page 227
        Why GetRows or Getstring to get Data (/learn/whygetrows.asp) - Page 228
        Speed: Server Optimization (/learn/speedserver.asp) - Page 229
        Speed/Optimize Resources (/learn/speedmore.asp) - Page 230
        Speed: [aspfastcode] listserver (/learn/speedresearch.asp) - Page 231
        Speed: Database Percieved Speed (/learn/speedtables.asp) - Page 232
        Database Retrieval Speed (/learn/speedtablesall.asp) - Page 233
        OLEDB & ODBC Drivers differences (/learn/speedtablesdrivers.asp) - Page 234
        IsClientConnected & Stray Tasks (/learn/isclientconnected.asp) - Page 235
        Scale: Virtues of Nothing (/learn/nothing.asp) - Page 236
        Scale: Connection Pooling (/learn/dbpooling.asp) - Page 237
        Thread Basics: What is a Thread? (/learn/threads.asp) - Page 238
        Thread Safety Issues (/learn/threadsafe.asp) - Page 239
        Round-Robin Code Execution (/learn/roundrobin.asp) - Page 240
        ASP Scalability Listserver (/learn/aspscalability.asp) - Page 241
ASP Components Building (/learn/buildcomponents.asp) - Page 242
        C++/ATL: Component Building (/learn/buildc.asp) - Page 243
        Java ASP Components Building (/learn/buildjava.asp) - Page 244
        VB: Simple Component (/learn/buildvbsimple.asp) - Page 245
        VB: Registering Component (/learn/buildregister.asp) - Page 246
        VB: DLL overwrite problems (/learn/FAQvbDLLoverwrite.asp) - Page 247
        VB: ADO, Run It! (/learn/buildvbado.asp) - Page 248
        VB: ADO, Build It! (/learn/buildvbado2.asp) - Page 249
        VB: Warnings/Guidelines (/learn/buildvbguidelines.asp) - Page 250
        VB: General Building Guidelines (/learn/buildvb.asp) - Page 251
        VB: Installation Requirements (/learn/buildvb2.asp) - Page 252
        VB: Threading Models (/learn/buildvbthreads.asp) - Page 253
MTS - Microsoft Transaction Server (/learn/buildmtx.asp) - Page 254
        MTS: Overview (/learn/buildmtxoverview.asp) - Page 255
        MTS: Essentials (/learn/buildmtx2.asp) - Page 256
        MTS: Transactional ASP pages (/learn/buildmtxasp.asp) - Page 257
        MTS: Book (/learn/booksmtx.asp) - Page 258
        MTS: Book (/learn/booksmtx2.asp) - Page 259
        MTS: Registering Components (/learn/buildmtxregister.asp) - Page 260
Advice For Better Coding! (/learn/advice.asp) - Page 261
        Database in Session or App. Say NO! (/learn/dbsessionapp.asp) - Page 262
        advice: Cache No More by Phil Paxton (/learn/cachenomore.asp) - Page 263
        advice:Option Explicit (/learn/explicit.asp) - Page 264
        advice: Encode with Redirects (/learn/encode.asp) - Page 265
        advice: Write Your SQL (/learn/sqlwrite.asp) - Page 266
        advice: Named constants for ADO are better (/learn/namedconstants.asp) - Page 267
        advice: Clean Up Your Room, I mean Objects (/learn/cleanup.asp) - Page 268
        advice: Server.MapPath is Good (/learn/pathmap.asp) - Page 269
        advice: Just Say No to Session COM objects (/learn/nosessionobjects.asp) - Page 270
        advice: Don't Read COM Properties Twice (/learn/propertyexpense.asp) - Page 271
        advice: Secure Code and Data (/learn/securecode.asp) - Page 272
        advice: Encaspulate Code! (/learn/encapsulate.asp) - Page 273
        advice: CASE reads better than IF (/learn/caseisbetter.asp) - Page 274
        advice: Error Trapping Strategies (/learn/errorstrategies.asp) - Page 275
        advice: Error Trapping Secrets (/learn/errorsecrets.asp) - Page 276
        advice: You Should... (/learn/shoulds.asp) - Page 277
Appendix A: Overview of ASP Objects (/learn/overview.asp) - Page 278
        ASP Objects: Built In (/learn/aspobjects.asp) - Page 279
        ASP Objects: Created when Needed (/learn/aspobjects2.asp) - Page 280
Appendix B: Related Web/Com Technologies (/learn/webcom.asp) - Page 281
        Index Server via ADO (/learn/indexserver.asp) - Page 282
        Commerce and ASP (/learn/commerce.asp) - Page 283
        Server JavaScript: Resources (/learn/javascript.asp) - Page 284
        Validation Resources (/learn/validationmore.asp) - Page 285
        Listboxes: Linked Dynamically w/JavaScript (/learn/listdynamic.asp) - Page 286
        Dynamic ListBox Online Examples (/learn/listdynamicmore.asp) - Page 287
        Listboxes: Linked Dynamically from Database w/JavaScript (/learn/listdynamicdb.asp) - Page 288
        Listboxes: Easy Choices by Bill Wilkinson (/learn/listdual.asp) - Page 289
        Server Perlscript: Resources (/learn/perlscript.asp) - Page 290
        Remote Scripting Simple Example (/learn/remotescripting.asp) - Page 291
        Remote Scripting Listbox (/learn/remotescriptinglist.asp) - Page 292
        Remote Scripting Microsoft Example (/learn/remotescriptingms.asp) - Page 293
        [aspRemoteScript] list (/learn/aspremotescripting.asp) - Page 294
        RDS: Remote Data Services Intro (/learn/rds.asp) - Page 295
        RDS Resources by Carl Prothman (/learn/prothman.asp) - Page 296
        ADSI: Active Directory Services Interface Intro (/learn/ADSI.asp) - Page 297
        MSMQ: Overview (/learn/MSMQ.asp) - Page 298
        Usability: Resources (/learn/usability.asp) - Page 299
        Usability: Safe Color Pallete (/learn/safecolors.asp) - Page 300
Appendix C: Oracle and ASP (/learn/oracle.asp) - Page 301
        Oracle: I can't connect (/learn/FAQOracleconnect.asp) - Page 302
        Oracle: Getting Help from Listserver (/learn/asporacle.asp) - Page 303
        Oracle: Calling Stored Procs (/learn/FAQOraclestoredproc.asp) - Page 304
        Oracle: OLEDB Resource(Session) Pooling (/learn/oracleoledbpooling.asp) - Page 305
        Oracle: Recordsets from Stored Procedures using REF CURSORs (/learn/oraclerecordsetsfromsp.asp) - Page 306
        Oracle: Returning Recordsets via ADO (/learn/oraclerecordsetsado.asp) - Page 307
        Oracle: Know any good books? (/learn/FAQOraclebooks.asp) - Page 308
Appendix D: ASP Books & Online Resources (/learn/research.asp) - Page 309
        Must Buy Component Building Book (/learn/bookcomponents.asp) - Page 310
        ASP101.com Scripts for your site (/learn/asp101.asp) - Page 311
        4GuysFromRolla.com Tons of ASP Material (/learn/4guysfromrolla.asp) - Page 312
        ASPToday.com from WROX (/learn/asptoday.asp) - Page 313
Appendix E: Frequently Asked Questions (/learn/faqs.asp) - Page 314
        Commerce: certificates, https:// (/learn/FAQCommerceCertif.asp) - Page 315
        Commerce: online charging (/learn/FAQCommerceCharge.asp) - Page 316
        Commerce: components, shopping carts (/learn/FAQCommerceCarts.asp) - Page 317
        Jscript: closing DB Connections (/learn/FAQJscriptCleanUp.asp) - Page 318
        Jscript: online references (/learn/FAQJscriptRefs.asp) - Page 319
        Jscript: display databases (/learn/FAQJscriptDB.asp) - Page 320
        VB: Recommended books (/learn/FAQvbBooks.asp) - Page 321
Alphabetical Index (/learn/alphaindex.asp) - Page 322
Coming Soon/Very Rough Drafts! (/learn/comingsoon.asp) - Page 323
        Data Types: VBScript (/learn/types.asp) - Page 324
        Data Types: Conversion (/learn/convert.asp) - Page 325
        Loops: FOR NEXT #1 (/learn/ForNext.asp) - Page 326
        Loops: FOR NEXT #2 (/learn/ForNext2.asp) - Page 327
        Ad Rotator (/learn/ad.asp) - Page 328
        Content Rotator (/learn/cr.asp) - Page 329
        DB: Command Object (/learn/command.asp) - Page 330
        DB: Command Object/Queries (/learn/commandquery.asp) - Page 331
        DB: Command Object/Create Tables (/learn/commandcreate.asp) - Page 332
        Reporting: Simple Example (/learn/reportsimple.asp) - Page 333
        Reporting: Powerful Example (/learn/reportpowerful.asp) - Page 334
        Dictionaries: Different Approach #1 By Paul Rigor (/learn/dictionaryadvanced.asp) - Page 335
        Dictionaries: Different Approach #2 by Paul Rigor (/learn/dictionaryadvanced2.asp) - Page 336
        Validate data (/learn/validate.asp) - Page 337
        3rd Party: WebJam (/learn/webjam.asp) - Page 338
        Time Tasks: VB Component by Sunny Yu #1 (/learn/asptime.asp) - Page 339
        Time Tasks: VB Component by Sunny Yu #2 (/learn/asptimer.asp) - Page 340
        Cookies: Reading Them (/learn/cookiesform.asp) - Page 341
        Cookies: Writing Them (/learn/cookiesformrespond.asp) - Page 342
        Cookies: Deleting Them (/learn/cookiesforget.asp) - Page 343
        Cookies: Simplified by Paul Rigor (/learn/cookiesub.asp) - Page 344


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/credits.asp Page 2


Credits for Tutorial at LearnASP.com

All material is ©1998-2000 by Charles Carroll. All rights reserved. May be used and printed for any single individual with no restriction. Cannot be reprinted, resold, or commercially made available without the written consent of Charles Carroll.

  Primary Writer/Site Programming:
     Charles M. Carroll

  Business Manager:
     Naoko Yoshitsugu

  Inspiration, Assistance, Motivation:
     Hitoshi & Michiko Carroll

     Contact Info

Additional Writers/Contributors:
    Aaron Alexander, Kevin Flick, Steve Genusa, Steven Harper, John Kauffman. Andrew Laken, Juan Llibre,  Rob Martinson, Phil Paxton,  George Reilly, Paul Rigor, Christophe Wille, David Wihl, and Sunny Yu.

thanks for feedback, support:
    Joao Oliveira contato123@zipmail.com.br
    Scott Mitchell www.4guysfromrolla.com

ASP Quick Lessons is a on-line book published @
http://www.learnasp.com

Recent family photos


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/core.asp Page 3


Section Contents

Core Ideas
        What is ASP? Obtaining The Software (whatis.asp) - Page 4
        AspInstall listserver (aspinstall.asp) - Page 5
        Simple ASP Page, Server Scripting (whatisexample.asp) - Page 6
        MS Online Documentation (docs.asp) - Page 7
        Response: Basics (res.asp) - Page 8
        Response: Buffers, Redirect (res2.asp) - Page 9
        Response: Redirection (res3.asp) - Page 10
        Response: Quotes & Special Characters (res4.asp) - Page 11
        Response: Encoding URLs, HTML (res5.asp) - Page 12
        Include: Basics (inc.asp) - Page 13
        Include: Dynamic FileName (includedynamic.asp) - Page 14
        Includes: Other Sites, Dynamic FileNames (includeasphttp.asp) - Page 15
        Include/Redirects: New Win2k Commands (incwin2k.asp) - Page 16
        Include: Books Sample Exercise (booksample.asp) - Page 17
        More Book Sample Exercises (booksample2.asp) - Page 18
        Format: Numbers #1 (formatnumbers.asp) - Page 19
        Format: Numbers #2 (formatnumbers2.asp) - Page 20
        Format: Dates #1 (formatdates.asp) - Page 21
        Date/Time on ASP Pages by Tony Arguelles (datetime.asp) - Page 22
        Loops: DO WHILE/UNTIL #1 (DoLoop.asp) - Page 23
        Loops: Timeouts #2 (DoLoop2.asp) - Page 24
        Loops: Intercepting Timeouts #3 (DoLoop3.asp) - Page 25
        Server Variables: Popular Ones (server.asp) - Page 26
        Server Variables: Domain/Host Name (server2.asp) - Page 27
        Server Variables: Displaying All (serverall.asp) - Page 28
        Random Content/Rotating Info (randomadvice.asp) - Page 29
        Browscap: Basics (bc.asp) - Page 30
        Browscap: Intricate Details (bcdetails.asp) - Page 31
        Listserver for Browser Problems (aspbrowserheck.asp) - Page 32


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/whatis.asp Page 4


subdates from ASP Quick Lessons

(surprisingly even though ASP was shipped in Feb 1996, most explanations are still HUGE in books and use quite scary technical terms) We will try to present this all in clear, concise terms and be complete as well. Hang on. Here we go.

ASP is:

  1. an abbreviation for Active Server Pages
  2. FREE and already built into Win2000. It is part of IIS and must be added with add/remove programs menu there.
  3. FREE for NT4 or Win 95/98 if one installs the NT4 Option Pack. Can be downloaded from http://www.microsoft.com/ntserver/nts/downloads/recommended/NT4OptPk/default.asp
    since ASP can be installed on Win 95/98 computers to test ASP scripts; thus we can  conclude the NT Option Pack4 has a very misleading name since it installs on Win 9x as well.
  4. The code inside ASP is mixed in with standard HTML and is NEVER seen by the browser. ASP pages run in ALL browsers UNLESS the person making the page uses HTML or browser commands outside of the ASP portions.

Tip: Trouble/Errors installing PWS? Here is the answer(s):

http://www.acceleratedcomputers.com/pws4.htm
has the answer to several annoying error messages!

http://rwebs.net/webdesign/pwsmore.htm
also has some excellent info about how and whether to install PWS.

Tip: Trouble/Errors installing IIS5?

When IIS5 does not start:
http://www.iisfaq.com/Articles/134/
 

More ASP facts:

  1. See www.learnasp.com/hosts for links to FREE hosts if you want to develop a site on the WWW web without spending money; Commercial hosts are also listed to serve busy corporate sites you build.
  2. It is part of IIS (Internet Information Server) which takes care of all the non-asp chores (FTP, serving plain HTML, serving video). IIS  is also FREE with NT4 or Win2000.
  3. It can be purchased for Unix, Notes/Domino, Novell servers and other platforms.  Two vendors currently offer this: Chilisoft and Halcyonsoft (see www.learnasp.com/hosts for links to them)

Are you one of those unlucky folks who gets cryptic errors or has trouble Installing Asp? Just join http://www.asplists.com/asplists/aspinstall.asp and submit your problem by email. Others will help you!


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/aspinstall.asp Page 5


Listserrver Join aspinstallListserver for more info @

http://www.asplists.com/asplists/aspinstall.asp

Related Links:

 
Excellent info about how and whether to install PWS @
   http://rwebs.net/webdesign/pwsmore.htm
The answer to several annoying error messages @
   http://www.acceleratedcomputers.com/pws4.htm
PWS NT Otion Pack4 WILL Install on Win9x @
   http://www.microsoft.com/ntserver/nts/downloads/recommended/NT4OptPk/default.asp

Recommended Books:

     

Related Lists:

Mobile lists by Asplists @
   http://www.asplists.com/asplists/mobile.asp
Mobile lists by WROX @
   http://p2p.wrox.com/mobile/

Rules:

Mailing List Manners (suggested by Bob Filipiak) @
   http://db.tidbits.com/getbits.acgi?tbser=1141
Ken Shaffer's Advice on Asking For Help... @
   http://www.adopenstatic.com/personal/help.asp


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/whatisexample.asp Page 6


subdates from ASP Quick Lessons

Now let us go over the essential mechanisms that are ASP:

  1. A user asks for a page say:
    http://www.coyoteindustries.com/hi.asp

  2. The Web Server find the file and then processes all the ASP code between <% ... %> before handing back the page. Code between  <% ... %> never arrives at the browser.
<html><head>
<TITLE>hi.asp</TITLE>
</head>
<body bgcolor="#FFFFFF">
Today is <%=now%> and all is well<br>
<%if hour(now())>12 THEN%>
Good Evening
<%ELSE%>
Good Morning!
<%END IF%>
</body></html>
The webserver file

<<<<<<<


ASP compiler grabs page
Interprets all the <% %> markers
before
browser sees page!
<html><head>
<TITLE>hi.asp</TITLE>
</head>
<body bgcolor="#FFFFFF">
Today is Tue 10:30am and all is well<br>
Good Morning
</body></html>
Before 12pm the user at the browser receives

<<<<<<<


<html><head>
<TITLE>hi.asp</TITLE>
</head>
<body bgcolor="#FFFFFF">
Today is Tue 02:00pm and all is well<br>
Good Day!
</body></html>
After 12pm the user at the browser receives

<<<<<<<


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/docs.asp Page 7


ASP/IIS Docs for Active Server Pages from MS

Microsoft Documentation

There is quite a bit of online documentation that comes with Microsoft Active Server Pages. Our tutorial was written with the express purpose of being a friendlier, easier to understand set of lessons than the free documentation Microsoft gives you below:

IIS4 Docs  
NT4 Option Pak /iishelp
ASP objects reference /iishelp/iis/htm/asp/intr1orp.htm
Ex Air /IISSamples/ExAir/default.asp
Installable Components for ASP /iishelp/iis/htm/asp/comp275c.htm
JScript Language Reference  /iishelp/JScript/htm/JStoc.htm
VBScript Language Reference /iishelp/VBScript/htm/VBStoc.htm
Server Side Include Reference  /iishelp/iis/htm/asp/iissiref.htm
ASP Quick reference card /iishelp/iis/htm/asp/iiwaref.htm
ASP Tutorial* click here
IIS3 Docs  
Roadmap / Official IIS3 Docs /iasdocs/aspdocs/roadmap.asp
IIS3 Code Samples /aspsamp/samples/samples.htm
AdventureWorks /AdvWorks/default.asp

* ASP Tutorial resides at this ridiculously long URL:
/iishelp/iis/htm/asp/iiselect.asp?LessonFile=%2Fiishelp%2Fiis%2Fhtm%2Fasp%2Fiiatmd1%


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/res.asp Page 8


Response Object ASP Quick Lessons

Response Object

The response object is useful, feature rich, and subtle. We are going to focus on it's most fundamental capabilities -- the 20% you will use 80% of the time. The capabilities we think are vital include:

Here is a script utilizing response.write to send some information to the browser. It also uses dateadd, a built-in function documented at http://help.activeserverpages.com/iishelp/VBScript/htm/vbs90.htm.

   <html><head>
   <title>response.asp</title>&
   <body color="#FFFFFF">
   <%
   when=now()
   tommorow=dateadd("d",1,when)
   twoweekslater=dateadd("ww",2,when)
   fourteenweekdayslater=dateadd("w",14,when)
   monthlater=dateadd("m",1,when)
10   
11   sixminuteslater=dateadd("n",6,when)
12   sixhourslater=dateadd("h",6,when)
13   fortysecslater=dateadd("s",40,when)
14   
15   response.write "Now <b>" & when & "</b><br>"
16   response.write "tommorow <b>" & tommorow & "</b><br>"
17   response.write "2 weeks from Now <b>" & twoweekslater & "</b><br>"
18   response.write "fourteen working days from Now <b>" & fourteenweekdayslater & "</b><br>"
19   response.write "1 month from Now <b>" & monthlater & "</b><br>"
20   %>

21   six minutes from now <b> <%=sixminuteslater%> </b><br>
22   six hours from now <b> <%=sixhourslater%> </b><br>
23   fourty seconds later <b> <%=fortysecslater%> </b><br>
24   </body></html>

Here is a script utilizing response.end to prematurely end a page:

   <html><head>
   <title>end.asp</title>&
   <body color="#FFFFFF">
   <%
   when=now()
   tommorow=dateadd("d",1,when)
   twoweekslater=dateadd("w",2,when)
   monthlater=dateadd("m",1,when)
   sixminuteslater=dateadd("n",6,when)
10   sixhourslater=dateadd("h",6,when)
11   
12   response.write "Now <b>" & when & "</b><br>"
13   response.write "1 month from Now <b>" & monthlater & "</b><br>"
14   response.end
15   response.write "2 weeks from Now <b>" & twoweekslater & "</b><br>"
16   %>

17   six minutes from now <b> <%=sixminuteslater%> </b><br>
18   six hours from now <b> <%=sixhourslater%> </b><br>
19   </body></html>


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/res2.asp Page 9


Buffering from ASP Quick Lessons

Response Object Part2 - Buffer Explanation

Does this error message plague you?

Response object error 'ASP 0156 : 80004005'
Header Error
whatever.asp, line
#
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.

The Simple Fix....
<%response.buffer=true%>
needs to be added as the very first line to any pages made by any HTML document that mixes redirects/headers and content.  And buffering is a great idea anyway from overall server speed viewpoint see http://www.learnasp.com/advice/whybuffer.asp).

One drawback to <%response.buffer=true%> is if a page takes a while to compose (i.e. a couple thousand records from a database) people see nothing until the page is completely rendered. If a page takes 20 seconds to render, the browser user sees nothing until the 20th second! In that situation to avoid appearing as the page is dead, a well-placed
<%response.flush%> tell server to send HEADER + whatever text so far so lets readers see the portions of the page being built. Increasing percieved speed of database displays is explained at http://www.learnasp.com/learn/speedtables.asp by judicous use of flushing buffer.

NT4 and Win 2000 differences

NT4 <%buffer=false%> by default which hurts overall server speed (http://www.learnasp.com/advice/whybuffer.asp). Win 2000 <%buffer=true%> by default. A clever administrator can change NT4 registry so buffer=true for all scripts and will see major server performance improvements (see http://www.learnasp.com/learn/speedserver.asp for other ones).

Here is a non-working page that will display the error:

   <%response.buffer=false%>
   <html><head>
   <title>dailystuff.asp</title>
   </head>
   <body>
   <%
   whatweekday=Weekday(now())
   select case whatweekday
   case vbSunday
10      response.redirect "http://www.cnn.com"
11   case vbMonday
12      response.redirect "http://www.activeserverpages.com"
13   case vbTuesday
14      response.redirect "http://www.aspalliance.com"
15   case vbWednesday
16      response.redirect "http://www.aspconvention.com"
17   case vbThursday
18      response.redirect "http://www.aspmagazine.com"
19   case vbFriday
20      response.redirect "http://www.dilbert.com"
21   case vbSaturday
22      response.redirect "http://www.movielink.com"
23   end select
24   %>

25   </body>
26   </html>

Here is the fixed page that will NOT display the error:

   <%response.buffer=true%>
   <html><head>
   <title>dailystuff.asp</title>
   </head>
   <body>
   <%
   whatweekday=Weekday(now())
   select case whatweekday
   case vbSunday
10      response.redirect "http://www.cnn.com"
11   case vbMonday
12      response.redirect "http://www.activeserverpages.com"
13   case vbTuesday
14      response.redirect "http://www.aspalliance.com"
15   case vbWednesday
16      response.redirect "http://www.aspconvention.com"
17   case vbThursday
18      response.redirect "http://www.aspmagazine.com"
19   case vbFriday
20      response.redirect "http://www.dilbert.com"
21   case vbSaturday
22      response.redirect "http://www.movielink.com"
23   end select
24   %>

25   </body>
26   </html>

Why? (The Tough Answer with Gory Details)

...first of all thanks to Ken Schaefer of Adopenstatic.com for pointing out huge flaws and misleading information in this page as it was written before 1/10/2001. Its revision on 1/10 was prompted by Ken. He wrote an article on this too at http://www.adopenstatic.com/faq/headererror.asp...

That line will do away with all "headers are already sent" messages. It essentially tells the server don't write anything at all to browser until
a) response.end executes thus stopping the page dead in tracks and sending to browser
b) response.flush executes
c) 100% of the page is executed and it finishes all the ASP and HTML.
d) response.redirect is sent (provided no content or text has been sent with response.flush)

An ASP page must be sent to browser in a specific strict order: first the header, and then the content. The header could contain cookies (see http://www.learnasp.com/learn/cookies.asp), redirects, other headers inserted by the response.addheader command and other header information. If your page mixes content (any text) and mixes in header info this is not following the strict rules. If the browser writes any data that is page content, and then headers cannot be sent -- it is "too late" -- it can't change "horses in midstream" -- that is header info cannot come inside or after data. Buffering does not send the page content and headers in exact order they appear in script. Even if headers and content is mixed the header and content are sent in correct order when buffer is flushed (either by explicit response.flush or script completes).


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/res3.asp Page 10


Res3 ASP Quick Lessons

Response Object - Redirects

The response object can be used to decide what page to send a user to next. Specifically the response.redirect method will work in that capacity. We have made a script formjump.asp that takes advantage of this.

   <html><head>
   <TITLE>FormJump.asp</TITLE>
   </head><body bgcolor="#FFFFFF">
   <form action="FormJumpRespond.asp" method="get">
   <SELECT NAME="wheretogo">
   <OPTION SELECTED VALUE="fun">Fun</OPTION>
   <OPTION value="news">Daily News</OPTION>
   <OPTION value="docs">ASP IIS3 Roadmap/Docs</OPTION>
   <OPTION value="main">MainPage of ActiveServerPages.com</OPTION>
10   <OPTION value="sample">IIS 3 Sample ASP scripts</OPTION>
11   </SELECT>
12   <input type=submit value="Choose Destination">
13   </form>
14   </body></html>

The responder that reacts to this form is:

   <%response.buffer=true%>
   <html><head>
   <title>formjumprespond.asp</title>&
   <body bgcolor="#FFFFFF">
   <%
   ' My ASP program that redirects to URL
   thisURL="http://www.activeserverpages.com"
   where=Request.QueryString("Wheretogo")
   Select Case where
10   case "main"
11         response.redirect thisURL & "/"
12   case "samples"
13         response.redirect thisURL & "/aspsamp/samples/samples.htm"
14   case "docs"
15         response.redirect thisURL & "/iasdocs/aspdocs/roadmap.asp"
16   case "news"
17         response.redirect "http://www.cnn.com"
18   case "fun"
19         response.redirect "http://www.dilbert.com"
20   End Select
21   response.write "All dressed up and I don't know where to go<br>"
22   response.write "I recommend --> " & "<br>"
23   response.write server.htmlencode(thisURL & "/learn/test/res2.asp?where=fun") & "<br>"
24   response.write "for a good laugh!" & "<P>"
25   %>

26   </body></html>


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/res4.asp Page 11


Res4 ASP Quick Lessons

Response Object and Quotes

The response object is often used with a variety of syntax variations which we will detail here.

   <html><head>
   <title>res4.asp</title>
   </head><body bgcolor="#FFFFFF">
   <%
   ' The response object can be used to write text a variety of ways
   ' depending on what style you personally prefer
   
   ' Various permutations of writing to the browser
   response.write "<form>"
10   response.write "Hello, Joe<br>"
11   
12   who="Joe"
13   response.write "Hello, " & who & "<br>"
14   %>

15   
16   Hello, <%=who%><br>
17   
18   Which Book? <input type="TEXT" name="book" value="The Stand"><br>
19   
20   <%
21   response.write "Which Book? <input type=""TEXT"" name=""book"" value=""The Stand""><br>"
22   %>

23   
24   <%
25   response.write "Which Book? <input type='TEXT' name='book' value='The Stand'><br>"
26   %>

27   
28   <%
29   quote=chr(34)
30   response.write "Which Book? <input type=" & quote & "TEXT" & quote & " name=" & quote & "book" & quote & " value=" & quote & "The Stand" & quote & "><br>"
31   %>

32   
33   
34   <%bookname="The Stand"%>
35   Which Book? <input type="TEXT" name="book" value="<%=bookname%>"><br>
36   
37   <%
38   response.write "Which Book? <input type=""TEXT"" name=""book"" value=""" & bookname & """><br>"
39   %>

40   </form>
41   </body></html>


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/res5.asp Page 12


Res5 ASP Quick Lessons

Response Object and HTML Encoding

The response object is often used in conjunction with various kinds of coding schemes. No discussion of response would be complete without a discussion of how to "handle" or "escape" special characters. This sample script demonstrates common conversion and transformation commands that make sense to use with the response.write command:

   <html><head>
   <title>res5.asp</title>
   </head><body bgcolor="#FFFFFF">
   <%
   ' The response object can be used to write text
   ' but sometimes some functions must be used to transform
   ' the text instead of sending as is to the browser
   
   response.write "<B>Hyperion</b> by <I>Dan Simmons</i> is a great novel"
10   response.write "<p>"
11   response.write server.htmlencode("<B>Hyperion</b> by <I>Dan Simmons</i> is a great novel")
12   response.write "<p>"
13   
14   
15   response.write "Joe Smith & Hilda = a team"
16   response.write "<p>"
17   response.write server.URLencode("Joe Smith & Hilda = a team")
18   %>

19   
20   </body></html>


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/inc.asp Page 13


Include Files ASP Quick Lessons Databases

Include Files

The include option is the heart of making efficient ASP files and re-usable chunks. It basically has two forms and now we will present the forms and their differences:

<!--#include virtual="/whatever.asp"-->
would include any file on your site (in this example, whatever.asp is in the web server's root directory) but you must fully qualify the filename with a path.

<!--#include file="whatever.asp"-->
can include the whatever.asp file in  the directory of the script that contains the statement. It ASSUMES the current directory!

Example #1
<!--#include virtual="/sally/filename.asp"-->
could include a file from sally's directory, even if the page with this statement is (for example) in the /fred/finance folder.

Example #2:
<!--#include file="/sally/filename.asp"-->
will fail from fred's directory.

Example #3:
<!--#include file="../sally/filename.asp"-->
will succed from fred's directory but if the script that contains it is moved to a different level in the tree structure it will fail to locate the file. INCLUDE VIRTUAL is better if a script may be moved and is immune to relative path issues.

IMPORTANT: Include files are always processed and inserted before ASP scripts on the page are calculated. Thus a page with many IFs and SELECT CASEs that selectively include files in fact always include the file before the script begins executing.


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/includedynamic.asp Page 14


Include Files Dynamically from ASP Quick Lessons

Includes Files Dynamically

The include files are gathered and processed BEFORE any ASP code. Soif your code looks like this:

<%SELECT CASE
     CASE 1 %>
    <!--#include virtual="whatever1.asp"-->
     CASE 2 %>

    <!--#include virtual="whatever2.asp"-->
     CASE 3 %>
    <!--#include virtual="whatever3.asp"-->
<%END SELECT%>

Three includes are performed before any ASP code is executed.

YOU CANNOT DO:

<%
     whichfile="1"%>
  <!--#include virtual="whatever<%=whichfil%>.asp"-->

Though this is a reasonable idea.

<!--#include virtual="whatever.asp"-->

We however have coded a workaround that is FREE you may find useful. The workaround is:

   <html><head>
   <TITLE>includedynamic.asp</TITLE>
   </head><body bgcolor="#FFFFFF">
   <%
   whichfile="bookscifi.asp"
   Call ReadDisplayFile(whichfile)
   response.write "<hr>"
   
   whichfile="bookhorror.asp"
10   Call ReadDisplayFile(whichfile)
11   response.write "<hr>"
12   
13   
14   whichfile="/learn/test/bookmarketing.asp"
15   Call ReadDisplayFile(whichfile)
16   response.write "<hr>"
17   %>

18   
19   </body></html>
20   <%
21   SUB ReadDisplayFile(FileToRead)
22      whichfile=server.mappath(FileToRead)
23      Set fs = CreateObject("Scripting.FileSystemObject")
24      Set thisfile = fs.OpenTextFile(whichfile, 1, False)
25      tempSTR=thisfile.readall
26      response.write tempSTR
27      thisfile.Close
28      set thisfile=nothing
29      set fs=nothing
30   END SUB
31   %>

The only downside to this method is no ASP Code ( i.e. anything in <% %> ) will be parsed or executed in the included file. If you must execute ASP code the Win2k server.execute @
/learn/incwin2k.asp
or the 3rd party components like ASPHTTP must be employed @
/learn/include/asphttp.asp


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/includeasphttp.asp Page 15


Includes - Other Sites, Dynamic Code

Includes - Other Sites/Dynamic FileNames

3rd party components like ASPHTTP can grab the HTML contents of a specific URL into an ASP string. Supports GET/POST/HEAD documents via the HTTP protocol, examining response headers, transfering requests to a file (including binary transfers) and password authentication support. They can also be used on YOUR OWN SITE to make dynamic includes possible.

available at http://www.serverobjects.com/products.htm

Microsoft includes WinInet which seems to be ideally suited for this EXCEPT is currently not thread safe, see:
http://www.learnasp.com/advice/threadsafe.asp
so Tools like ASPHTTP are a necessity.

Here is a sample where ASPHTTP is used to grab contents from another site.

   <html><head>
   <title>asphttpother.asp</title>
   </head>
   <body>
   <%
         Set HttpObj = Server.CreateObject("AspHTTP.Conn")
   
         HttpObj.Url = "http://www.funinspace.com"
         strResult = HttpObj.GetURL
10         
11         STRresult=server.htmlencode(STRresult)
12         response.write STRresult
13   
14         SET HTTPobj = nothing
15   %>

16   </body>
17   </html>
18   
19   

Here is a sample where ASPHTTP is used to allow a string to decide  which page on our site is executed.

   <html><head>
   <title>asphttpdynamic.asp</title>
   </head>
   <body bgcolor="#FFFFFF">
   <%
      mystring="/learn/test/response.asp"
   
         Set HttpObj = Server.CreateObject("AspHTTP.Conn")
         HttpObj.Url = "http://www.learnasp.com" & mystring
10         strResult = HttpObj.GetURL
11         response.write STRresult
12   
13         SET HTTPobj = nothing
14   %>

15   </body>
16   </html>
17   
18   


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/incwin2k.asp Page 16


Include Files ASP Quick Lessons Databases

Include/redirect Goodies from Win2000

Win 2000 introduces two new ways to deal with redirects and includes:

server.transfer
which unlike redirect, does not interact with the browser. The server switches to a different page/site without any browser interaction or headers.

server.execute
which can take a dynamically generated string and execute the code in the asp script named by the string.


ASP Quick Lessons written by Charles M. Carroll
http://www.learnasp.com/learn/booksample.asp Page 17


Book Sample from ASP Quick Lessons

Book Sample by Charles Carroll

The Recommend Book Sample Files provides you with several files that when created, prepare you for applying several powerful content management tools and session examples in the following pages. The features detailed will include:

all come together in this example.

Here is the code for bookheader.asp:

   Recommended Books for <%=session("fname")%> &nbsp; <%=session("lname")%><br><hr>

Here is the code for bookfooter.asp:

   <hr><br>
   Recommended Books has <%=application("howmany")%> people reading it now!

Here is the code for bookfuture.asp:

   <html><head>
   <title>bookfuture.asp</title>&
   <!--#include file="bookheader.asp"-->