Courtenay's Snippets

ASP libraries and code snippets

These are included in the "pincers" directory in the site download!

In addition to the above I've have a collection of functions and classes for Classic ASP that I use when developing. They tend to take the pain away form the repetitive tasks. Hand writing an ASP selectlist HTML in While / wEnd conditions and wrapping the pre-selects in If statements - can suck your will to live.
One of my snippets include a class that can help remove the tedium . Here' some example code:

ASP Selectlist

First include the class at the top of the page:

<!--#include file="SelectList.class.asp" -->

Then programmatically script the HTML for a select list in as little as 5 lines of code.

<%

Function drawSelectlist()

' Create instance of SelectList Class
Dim mySelect : Set mySelect = New SelectList
' Set the select tag's ID and Name
mySelect.SelectID = "SelectMe"
' Set as many manual options as you want
- [OPTIONAL]
mySelect.AddOption = "<option value=''>Please Select </option>"
' The SQL can only contain two values: [ID] First - [Label] Second
mySelect.SQL ="SELECT x AS value, y AS name FROM z "
mySelect.ConnString = myConn ' The Connection string to the DB
' The pre select values can be an integer an array or a comma separated list of values to pre select - [OPTIONAL]
mySelect.PreSelect = 25
Dim SelectList : SelectList = mySelect.SelectList() ' Returns the HTML

End Function

Response.Write(drawSelectlist) ' any where in your page
%>

There are more options available such as debugging and even datashaping see the example for further details.

For further examples of my reuserable code snippets see: Documentation

As with all examples on this site the best place for additional information is in the source code!