<%
Server.ScriptTimeout=600
Response.Buffer=True
Response.Expires=0
If (VarType(Application("~WC~WebClassManager")) = 0) Then
Application.Lock
If (VarType(Application("~WC~WebClassManager")) = 0) Then
Set Application("~WC~WebClassManager") = Server.CreateObject("WebClassRuntime.WebClassManager")
End If
Application.UnLock
End If
Application("~WC~WebClassManager").ProcessNoStateWebClass "Project1.WebClass1", _
Server, _
Application, _
Session, _
Request, _
Response
%>
Figure 7 HTML Template WebItem
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<P style="BACKGROUND-COLOR: forestgreen"> </P>
<P><STRONG><FONT face="" size=5>Pubs Database
Search</FONT></STRONG> </P>
<P style="BACKGROUND-COLOR: white">Click to see a list of all Authors from the Pubs database</P>
<form method=post id=ListAuthors>
<P><INPUT id=btnAuthors name=button1 type=submit value=Authors></P>
</form>
<A href="" id =Hlink >Second Page Link</A>
</BODY>
</HTML>
Figure 8 WebClass Designer
Figure 9 Importing a Template WebItem
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<P style="BACKGROUND-COLOR: darkblue"><STRONG><FONT face=""
size=4></FONT></STRONG> </P>
<P align=center><STRONG><FONT face="" size=4>Just some other
html file you want to display!</FONT></STRONG></P>
<P style="BACKGROUND-COLOR: royalblue"><STRONG><FONT face="" size=4>
</FONT></STRONG> </P>
</BODY>
</HTML>
Figure 10 ShowAuthors Respond Event
Dim rs As ADODB.Recordset
Dim db As CDBLookup
Set db = New CDBLookup
Set rs = db.DBLookUp()
If rs.EOF And rs.BOF Then
Else
With Response
.Write "<HTML><BODY><H1>Authors</H1><HR>"
.Write "<TABLE border=1 width=80% cellpadding=1>"
.Write "<TR><TH>Author ID</TH><TH>Name</TH></TR>"
Do Until rs.EOF
.Write "<TR><TD>" & rs("Au_ID") & "</TD>"
.Write "<TD><a href=""" & URLFor("Titles", CStr(rs("au_id"))) _
& """>" & rs("au_lname") & ", " & rs("au_fname") &
"</a></TD></TR>"
rs.MoveNext
Loop
.Write "</TABLE></BODY></HTML>"
End With
End If
Figure 11 Tag Substitution
<HTML>
<HEAD>
<TITLE>Author Titles</TITLE>
</HEAD>
<BODY>
<P ><FONT face="" size=4><STRONG>Titles for this Author</STRONG></FONT></P><HR>
<table border=0 cellpadding=3 width=90%>
<tr>
<th>Author ID</th><td><wc@AUID>Au_ID </wc@AUID></td>
<th>Title</th><td><wc@title> title </wc@title></td>
<th>Price</th><td><wc@PRICE> Price </wc@PRICE></td>
</tr>
</table>
<P> </P>
</BODY>
</HTML>
Figure 12 Author Search Query
Private Sub Titles_UserEvent(ByVal EventName As String)
Dim db As CDBLookup
Set db = New CDBLookup
'rsTitles is declared at the module level in order to
'be available to the ProcessTag event
Set rsTitles = db.TitleLookUp(EventName)
'calls Titles_Respond event
Set NextItem = Titles
End Sub
Figure 13 TitleLookUp
Public Function TitleLookUp(au_id As String) As Recordset
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
sql = "Select A.Au_id,Title, Price "
sql = sql & "From Authors A, Titles T, TitleAuthor TA "
sql = sql & "Where A.au_id = TA.au_id and "
sql = sql & "T.title_id = TA.title_id and "
sql = sql & "A.au_id = '" & au_id & "'"
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.LockType = adLockReadOnly
conn.Open CONNECT
rs.Open sql, conn
Set rs.ActiveConnection = Nothing
conn.Close
Set conn = Nothing
Set TitleLookUp = rs
End Function
Figure 14 Login Page
<STYLE>
P
{
COLOR: red;
FONT-FAMILY: Comic Sans MS;
FONT-SIZE: Large;
FONT-WEIGHT: bolder;
TEXT-ALIGN: center
}
BODY
{
BACKGROUND-COLOR: black;
}
DIV
{
TEXT-ALIGN: center;
COLOR: white;
FONT-FAMILY: Arial
}
</STYLE>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<FORM NAME="LOGON" Action="" Method=POST>
<P>Login Page</P>
<wc@loginMessage>Au_ID</wc@loginMessage>
<DIV>
Username<INPUT id=UserID name=txtID style="HEIGHT: 22px; WIDTH: 134px">
<BR>
Password<INPUT id=Password name=txtPassword type=password style="HEIGHT: 22px; WIDTH: 134px">
</DIV>
<P>Enter you user name and password</P>
<P><INPUT id="Logon" type="submit" name="Action" style="FONT-SIZE: medium" value="Logon"></P>
</FORM>
</BODY>
</HTML>
Figure 15 Adding a Login Page
Figure 16 Login Custom Event
Private m_LoggedIn As Boolean
Private Sub Logon_Logon()
Dim strID$, strPwd$
strID = Request.Form("txtID")
strPwd = Request.Form("txtPassword")
If strID = "12345" And strPwd = "Password" Then
m_LoggedIn = True
Set NextItem = FirstPage
Else
m_LoggedIn = False
Response.Redirect URLFor("Logon")
End If
End Sub