|
hyBook - A Simple Guestbook Application
Part:
1
2
3
4
5
6
7
8
9
10
11
12
13
(Continued from previous part...)
Function htmlNotice(sText)
Response.Write("<table class=hy_notice>")
Response.Write("<tr><td>" & sText & "</td></tr>")
Response.Write("</table>")
End Function
Function htmlError(sText)
Response.Write("<table class=hy_error>")
Response.Write("<tr><td>" & sText & "</td></tr>")
Response.Write("</table>")
End Function
Function myTrim(sText,nLen)
myTrim = sText
If myTrim <> "" Then
myTrim = Trim(sText)
If Len(myTrim) > nLen Then
myTrim = Mid(myTrim, 1, nLen)
End If
myTrim = removeHTML(myTrim)
End If
End Function
Function myDump
aKeys = hgRqParam.Keys()
ogDebug.WriteLine("Values in hgRqParam:")
For i=0 To hgRqParam.Count-1
k = aKeys(i)
ogDebug.WriteLine(k & " = (" & hgRqParam.Item(k) & ")")
Next
aKeys = hgPgParam.Keys()
ogDebug.WriteLine("Values in hgPgParam:")
For i=0 To hgRqParam.Count-1
k = aKeys(i)
ogDebug.WriteLine(k & " = (" & hgPgParam.Item(k) & ")")
Next
End Function
%>
Some very interesting techniques used in this page:
- This page is also driven by the configuration file, _config.inc, and the template file, _template.inc.
- All functions in this page are grouped under three Boolean flags: bgShowDetail, bgShowList, and bgDoSubmit.
- A single password is used control the function flags. Of course, you should change this password,
if you want to use my page.
- Three dictionary objects are used to maintain user values: hgRqParam, hgDbParam, and hgPgParam, where
hgRqParam stores values received from the user; hgDbParam stores values processed from hgRqData and ready
for database SQL statements; and hgPgParam stores values that are safe to be used in HTML output.
- doSubmit() function is designed to receive all user input values and call other handler functions
for each type of user submission like: Search, Clear, Update, Insert, Select, or Delete.
- Search result is displayed as a list with radio button on each item for selection or deletion.
- Selected record is displayed in a form for viewing or updating. The same form can also be used
to insert a new record.
Conclusion
- hyBook is simple guestbook tool. You can use it directly on your Web site, or use it to learn various
techniques for writing database applications.
- hyBook shows you how to make a Web application configurable with a configuration file, a template file,
and a CSS file.
- When composing SQL statements, all values must checked for quoting characters.
- hyBook administration page shows you some interesting ASP coding techniques on managing table records.
- If you are interested in download and install hyBook, go to http://www.herongyang.com/hyBook/.
Part:
1
2
3
4
5
6
7
8
9
10
11
12
13
|