<% '******************************************************* '* ASP 101 Sample Code - http://www.asp101.com/ * '* * '* This code is made available as a service to our * '* visitors and is provided strictly for the * '* purpose of illustration. * '* * '* http://www.asp101.com/samples/license.asp * '* * '* Please direct all inquiries to webmaster@asp101.com * '******************************************************* %> Samples <% HR %> <% Sub WriteTableRow(sFileName, sSampleName, sSampleDesc, iRating, bNew, bASPX) Dim I 'As Integer Response.Write "" & vbCrLf Response.Write vbTab & "" & sSampleName & "" & vbCrLf Response.Write vbTab & "" & sSampleDesc If bNew Then Response.Write "  " Response.Write "" & vbCrLf Response.Write vbTab & "" If bASPX Then Response.Write "" Else Response.Write " " End If Response.Write "" & vbCrLf Response.Write vbTab & "" For I = 1 to iRating Response.Write "" Next 'I Response.Write "" & vbCrLf Response.Write "" & vbCrLf End Sub %>
ASP Wherever you see this image you can click on it to see the actual ASP code that generated the corresponding page. So it stands out, ASP code is displayed as blue text and ASP comments are green text.
HTML Likewise where you see this image you can click on it to see a previously run sample of HTML that was generated by the script.
HTML Due to popular demand, when you click on this image, you'll get a plain text version of the script. You can either save the whole file or cut and paste it directly into your own script!

ASP.NET
In order to begin introducing our users to some of the exciting new features and coding style of ASP.NET, we're publishing ASP.NET versions of a number of our existing samples which will be indicated by this symbol. We feel the benefits to this approach are two-fold.
  1. You get some exposure to ASP.NET code (obviously)
  2. You get to compare the two sets of code and see the differences for yourself

<% WriteTableRow "adrotator.asp", "Ad Rotator", "The Ad Rotator component does all the hard work for you.", 1, False ,True WriteTableRow "db_xml.asp", "ADO to XML", "Save a recordset as an XML file using ADO.", 1, False ,True WriteTableRow "altcolors.asp", "Alternating Colors", "For when you want alternating colored table rows.", 1, False ,True WriteTableRow "array.asp", "Array (1D)", "Sometimes one value per variable just isn't enough.", 1, False ,True WriteTableRow "barcode.asp", "Barcode", "Generate code 39 symbology barcodes for use on your web pages.", 2, False ,True WriteTableRow "bar_chart.asp", "Bar Chart", "Turn those numbers into something useful!", 2, False ,True WriteTableRow "bar_chart_stacked.asp", "Stacked Bar Chart", "A stacked version!", 2, False ,False WriteTableRow "byrefbyval.asp", "ByRef vs. ByVal", "Passing parameters by reference or by value.", 1, False ,True WriteTableRow "calendar.asp", "Calendar", "Darn, what day is my birthday on in 2010? I need to start planning!", 3, False ,True WriteTableRow "case.asp", "Cases", "Demonstrates how to create and select a Case.", 1, False ,True WriteTableRow "checkbox.asp", "Checkbox", "Find out how to handle checkboxes like a pro.", 1, False ,True WriteTableRow "checkbox2db.asp", "Checkbox to Database", "Displaying and saving boolean data via a checkbox.", 2, False ,False WriteTableRow "colors.asp", "Colors", "All the colors of the (color-safe palette) rainbow.", 2, False ,True WriteTableRow "color_chooser.asp", "Color Chooser", "Sometimes it's nice to see the colors.", 1, False ,True WriteTableRow "cookie.asp", "Cookies", "No cookie monsters here.", 1, False ,True WriteTableRow "custom.asp", "Customization", "Let users customize their view of your site.", 2, False ,True WriteTableRow "db_simple.asp", "Simple Database", "Uses info from a database table to build an HTML table.", 1, False ,True WriteTableRow "database.asp", "Database", "Accessing an Access database.", 2, False ,True WriteTableRow "db_add.asp", "Database Add", "Part 1 of our DB editing trilogy: Add!", 1, False ,True WriteTableRow "db_del.asp", "Database Delete", "Part 2: The Delete Strikes Back!", 1, False ,True WriteTableRow "db_update.asp", "Database Update", "Part 3: Return of the Update!", 1, False ,True WriteTableRow "db_count.asp", "Database Count", "How to get a RecordCount that doesn't return -1!", 2, False ,True WriteTableRow "db_edit.asp", "Database Editing", "Add, delete, and edit from one script.", 3, False ,True WriteTableRow "db_getrows.asp", "Database GetRows", "Get all your recordset rows at once!", 2, False ,False WriteTableRow "db_getstring.asp", "Database GetString", "No more looping through recordsets!", 2, False ,False WriteTableRow "db_highlight.asp", "Database Highlight", "A virtual highlighter to make reading database data easier.", 2, False ,True WriteTableRow "db_paging.asp", "Database Paging", "Previous 10, Next 10... you know you want it!", 2, False ,True WriteTableRow "db_pulldown.asp", "Database Pulldown", "Fill your pulldowns with data from a Database!", 2, False ,True WriteTableRow "db_pulldown_linked.asp", "Database Pulldown (Linked)", "Modify a pulldown's options based on other input.", 2, False ,True WriteTableRow "db_rec_kill.asp", "DB Record Killer", "A version of our DB Delete script on steroids.", 2, False ,True WriteTableRow "db_search.asp", "Database Search", "Perform a simple text search on a database.", 2, False ,True WriteTableRow "db_paged_search.asp", "Database Paged Search", "Two cool DB scripts rolled into one!", 3, False ,True WriteTableRow "db_search_multi.asp", "Database Search (Multi-Term)", "Learn how to search for multiple query terms.", 2, False ,True WriteTableRow "db_sort.asp", "Database Sort", "Sort data tables simply by clicking.", 2, False ,True WriteTableRow "db_sort_multi.asp", "Database Sort (Multi)", "Now you can sort by multiple fields.", 3, False ,True WriteTableRow "db_trans.asp", "Database Transactions", "When you need to be sure something gets done.", 2, False ,True WriteTableRow "dictionary.asp", "Dictionary", "Manage key / item pairs with ease.", 1, False ,True WriteTableRow "dir_list.asp", "Directory List", "Directory browsing made pretty!", 2, False ,True WriteTableRow "dir_list_sort.asp", "Directory List (Sorted)", "Sort the results of our Dir List script.", 3, False ,True WriteTableRow "dir_list_filtered.asp", "Directory List (Filtered)", "List only the files whose filenames match the text you enter.", 2, False ,True WriteTableRow "dir_list_clicksort.asp", "Directory List (Click to Sort)", "Let your users sort file listings any way they want.", 3, False ,False WriteTableRow "dir_to_rst.asp", "Directory List to Recordset", "Use a Recordset to manipulate non-database data.", 2, False ,True WriteTableRow "download_sample.asp", "Download", "Get that download dialog box to pop up.", 2, False ,True WriteTableRow "form_dynamic.asp", "Dynamic Form Fields", "It pays to be flexible when designing forms to get mystery data.", 2, False ,True WriteTableRow "email.asp", "E-mail", "How to send an e-mail message from your web server using CDO.", 1, False ,True WriteTableRow "email_html.asp", "E-mail (HTML)", "Send email messages as lively as a web page.", 1, False ,True WriteTableRow "email_attach.asp", "E-mail (with Attachment)", "Attach files to the messages you send.", 1, False ,True WriteTableRow "elseif.asp", "ElseIf", "No, it's not a typo...", 1, False ,True WriteTableRow "error.asp", "Error Handling", "You can't prevent errors, but you can prevent users from seeing them.", 2, False ,True WriteTableRow "xl.asp", "Excel", "Use Excel as a client-side data viewer.", 1, False ,True WriteTableRow "xl_data.asp", "Excel Data", "There actually are reasons why you'd want to do this!", 2, False ,True WriteTableRow "file_attrib.asp", "File Attributes", "Check to see which attributes a file has set.", 2, False ,True WriteTableRow "file_exists.asp", "File Exists", "Check to see if a file exists on the server's file system.", 1, False ,True WriteTableRow "flextable.asp", "Flex Table", "A flexible table with paging support!", 2, False ,True WriteTableRow "form_handler.asp", "Form Handler", "Some light form validation and error notification.", 2, False ,True WriteTableRow "form_to_db.asp", "Form to DB", "Insert records retrieved from a form into a database.", 2, False ,True WriteTableRow "form_viewstate.asp", "Form ViewState", "Persisting form values in classic ASP may be a pain, but someone's got to do it.", 2, False ,True WriteTableRow "function.asp", "Functions", "A basic use of a function that can save redundant code.", 1, False ,True WriteTableRow "getpost.asp", "Get vs. Post", "The age-old debate examined via ASP.", 1, False ,True WriteTableRow "welcome.asp", "Greeting", "Greet your user based on the time of day.", 1, False ,True WriteTableRow "guestbook.asp", "Guestbook", "Let your guests sign in.", 2, False ,True WriteTableRow "guestbook_top.asp", "Reverse Guestbook (Compatible)", "A guestbook where new entries go on top. (Same file format as guestbook.asp)", 2, False ,True WriteTableRow "guestbook_top_fast.asp", "Reverse Guestbook (Faster)", "A guestbook where new entries go on top. (New file format and more efficient)", 2, False ,False WriteTableRow "hangman.asp", "Hangman", "Just hanging around!", 3, False ,False WriteTableRow "world.asp", "Hello World", "The classic beginning script for any language implemented in ASP.", 1, False ,True WriteTableRow "counter.asp", "Hit Counter", "Count hits to your pages.", 1, False ,True WriteTableRow "counter_db.asp", "Hit Counter (DB)", "Another hit counter, but using a database instead of text files.", 1, False ,True WriteTableRow "http.asp", "Http Request", "Sometimes it's helpful to get data from other servers... here's how.", 2, False ,True WriteTableRow "winhttp5.asp", "Http Request (WinHTTP v5.0)", "Make requests using MS's WinHTTP v5.0.", 2, False ,False WriteTableRow "http_cache.asp", "Http Request (Cached)", "I simply can't overstate the importance of caching data retrieved via HTTP requests.", 2, False ,True WriteTableRow "http_post.asp", "Http Request (Post Method)", "Post form data to a remote server behind the scenes.", 2, False ,True WriteTableRow "imageflip.asp", "Image Flip", "Apply transformations to an image before sending it to the browser.", 3, True ,True WriteTableRow "modified.asp", "Last Modified", "Get the last modified date from your ASP files.", 2, False ,True WriteTableRow "links.asp", "Link Manager", "Manage the links on your page from your browser!", 3, False ,False WriteTableRow "login.asp", "Login & Password", "Secure an ASP page simply and easily.", 2, False ,True WriteTableRow "min-max.asp", "Min / Max", "The highs and lows of ASP coding!", 2, False ,True WriteTableRow "multiple_selection.asp", "Multiple Selections", "Why limit your users to one choice... let em choose away!", 1, False ,True WriteTableRow "nametag.asp", "Name Tag", "Add text to an image before serving it to the browser.", 3, True ,True WriteTableRow "output.asp", "Output", "Response.Write, Carriage Returns, vbCrLf, and more fun stuff!", 1, False ,True WriteTableRow "time.asp", "Page Timer", "How long are people spending filling out your forms?", 2, False ,True WriteTableRow "phonemsg.asp", "Phone Message", "A virtual "While You Were Out" pad.", 2, False ,False WriteTableRow "phone_format.asp", "Phone Number", "Format your phone numbers so they're all uniform.", 1, False ,True WriteTableRow "photos.asp", "Photo Gallery", "Show your photos with style.", 2, False ,True WriteTableRow "polls.asp", "Poll", "Poll your users. It's like the quiz, but it's not!", 3, False ,True WriteTableRow "progress.asp", "Progress Bar", "Are we there yet.... how much longer?", 1, False ,True WriteTableRow "pcase.asp", "Proper Case", "There's LCase and UCase... and now PCase!", 1, False ,True WriteTableRow "pulldown_nav.asp", "Pulldown Navigation", "Navigate around your site using a pulldown box!", 2, False ,True WriteTableRow "quiz.asp", "Quiz", "Test your visitors' knowledge!", 3, False ,False WriteTableRow "radiobutton.asp", "Radio Button", "Not quite like the ones in your parents' old car.", 1, False ,True WriteTableRow "random_number.asp", "Random Number", "Generate a random number using ASP.", 1, False ,True WriteTableRow "random_image.asp", "Random Image", "Not 1 or 2, but 3 ways to display a random image!", 2, False ,True WriteTableRow "server_execute.asp", "Server.Execute", "Relax... we're not going to kill your server!", 1, False ,True WriteTableRow "servvars.asp", "Server Variables", "Find out what your clients are telling you.", 1, False ,True WriteTableRow "shopping.asp", "Shopping Cart", "Let's go shopping. Cool ASP 101 merchandise!", 3, False ,False WriteTableRow "source.asp", "Source Code", "View source code of the script that lets you view our source code.", 2, False ,True WriteTableRow "storedprocs.asp", "Stored Procs", "Using SQL Server's stored procedures isn't that hard.", 2, False ,True WriteTableRow "storedqueries.asp", "Stored Queries (Access)", "They're not quite stored procedures, but they do work.", 2, False ,True WriteTableRow "tell_a_friend.asp", "Tell a Friend", "Have users tell their friends about a resource on your site.", 2, False ,True WriteTableRow "textfile.asp", "Text Files", "Learning to read and write all over again.", 2, False ,True WriteTableRow "textfilesearch.asp", "Text File Search", "Search for a specific phrase in a text file.", 2, False ,True WriteTableRow "db_dsn.asp", "Universal DB Viewer", "View any database on the web. Just plug in your DSN and go!", 3, False ,False WriteTableRow "url_linker.asp", "URL Linker", "Automatically link every http:// in a string", 1, False ,True WriteTableRow "var_types.asp", "Variable Types", "Type mismatch?... but I thought everything was a variant.", 2, False ,True WriteTableRow "weblog.asp", "Web Log", "A simple web log for adding news links to your site.", 2, False ,True WriteTableRow "wizard.asp", "Wizard", "Break complex tasks into smaller, easy to manage pieces.", 2, False ,True WriteTableRow "wordcount.asp", "Word Count", "Counts the words and characters in a string.", 1, False ,True WriteTableRow "wordwrap.asp", "Word Wrap", "Word wrap your text for emailing or pre tags.", 2, False ,True WriteTableRow "xmlxsl.asp", "XML to HTML (via XSL)", "Use a XSL stylesheet to apply transformations to an XML file.", 2, False ,True WriteTableRow "y2k.asp", "Year 2000", "If the cookie monster didn't scare you this should.", 1, False ,True %>
Sample Name Description ASP.NET Complexity

These samples are placed here for your reference. Each one will give you sample output, the .asp source file, and the .htm file that is generated when a user runs the .asp script. This code is strictly for the sake of illustration. Most of it includes little to no error handling and we therefore cannot be held responsible for anything it may do when run on your server.

Having said that, we will not intentionally place any malicious code here and will try and warn you of anything a script may do which might be unexpected (ie. writing to the server's hard drive). Still, if you do encounter any errors or side effects when attempting to run any of our code, please let us know and we'll do our best to assist you in getting it to run correctly and update our example with the appropriate fix and/or warning.

For those of you who keep asking if you can use the code read this.