مشخصات کتاب
-
Omar Elbaga and Rob Turnbull
-
2006
-
انگلیسی
-
2623
-
202
-
0
Foundation ASP for Dreamweaver 8
CONTENTS
About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Chapter 1 Dreamweaver and Dynamic Sites . . . . . . . . . . . . . . . . . . . . 1
Data exchange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Dynamic takes over static . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Dreamweaver server models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
The ASP VBScript server model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
What Dreamweaver 8 offers you as an ASP developer . . . . . . . . . . . . . . . . . . . . 9
Checking out data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Connecting to databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Where is ASP in Dreamweaver? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
ASP features supported by Dreamweaver . . . . . . . . . . . . . . . . . . . . . . . . 10
Insert bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
The Insert bar’s ASP tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
The Insert bar’s Application tab . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Application panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
The Databases tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
The Bindings tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Chapter 2 The Dreamweaver Environment . . . . . . . . . . . . . . . . . . . . 19
Workspace layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
The Multiple Document Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
The CSS panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
The Application panel group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
The Databases panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
The Bindings panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
The Server Behaviors panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
The Tag Inspector panel group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
The Attributes panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
The Behaviors panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
vii
CONTENTS
0e197eab08414336a67d4228a6088055
The Files panel group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
The Files panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
The Assets panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
The Snippets panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
The Properties panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
The Results panel group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
The Search panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
The Validation panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
The Target Browser Check panel . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
The Link Checker panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
The Site Reports panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
The FTP Log panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
The Server Debug panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
The Reference panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
The Insert toolbar/panel group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
The Document toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
The Standard toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
The Style Rendering toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
The Coding toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
New tools in Design view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Zoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Magnification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Hand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Guides . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Defining an ASP VBScript site in Dreamweaver . . . . . . . . . . . . . . . . . . . . . . . 39
Local Info screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Remote Info screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Testing Server screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Creating the site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Chapter 3 A First Taste of ASP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Specify your language: VBScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
ASP delimiters <% %> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Insensitive case! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Declaring and printing variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Letting VBScript declare variables implicitly . . . . . . . . . . . . . . . . . . . . . . . 52
Syntax rules for variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Data types: string, integer, and Boolean . . . . . . . . . . . . . . . . . . . . . . . . . 52
Variable concatenation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Watching out for “adding” numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Variable naming conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Prefixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Using understandable variable names . . . . . . . . . . . . . . . . . . . . . . . . 56
Commenting code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
CONTENTS
viii
VBScript’s house of built-in functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Conversion functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
String functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Assignment operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Logical operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
AND, OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
NOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Comparison operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Mathematical operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Operator precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Conditional logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
The If statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
The If . . . Then . . . Else statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
The If . . . Then . . . ElseIf statement . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Looping logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
The Do . . . Loop statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
The While . . . Wend statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Cookies (ASP cookies, not chocolate chip!) . . . . . . . . . . . . . . . . . . . . . . . . . 72
Response.Cookies and Request.Cookies . . . . . . . . . . . . . . . . . . . . . . . . . 73
Cookie expiration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Updating cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Deleting cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
A word of warning about the use of cookies . . . . . . . . . . . . . . . . . . . . . . 76
Session variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Setting the session timeout interval . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Creating and retrieving session variables . . . . . . . . . . . . . . . . . . . . . . . . . 77
Updating session variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Deleting session variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Note on sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Environment variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Chapter 4 Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Creating a database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Inside Microsoft Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Inside Microsoft SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Preparing a SQL Server database for Internet use . . . . . . . . . . . . . . . . . . . . . . 88
Creating the IUSR account in SQL Server . . . . . . . . . . . . . . . . . . . . . . . . 89
Database design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Object naming conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Creating tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Creating tables in Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Creating tables in SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Relational databases and referential integrity . . . . . . . . . . . . . . . . . . . . . . . . 97
Creating a relationship in Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Creating a relationship in SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . 100
SQL Server views and Access queries . . . . . . . . . . . . . . . . . . . . . . . . . . 102
CONTENTS
ix
Fundamental SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Selecting all records from a table . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Selecting all records that meet one criterion . . . . . . . . . . . . . . . . . . . . . . 104
Selecting all records that meet several criteria (using AND) . . . . . . . . . . . . . 105
Selecting records that meet one or more of several criteria (using OR) . . . . . . . 105
Useful SQL keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
COUNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
SUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
TOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
BETWEEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
ORDER BY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
IN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
GROUP BY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
DISTINCT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Going on a DATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Making the connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Setting up a DSN to an Access database . . . . . . . . . . . . . . . . . . . . . . . . 114
Setting up a DSN to a SQL Server database . . . . . . . . . . . . . . . . . . . . . . 114
Connecting from Dreamweaver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
The Simple Recordset builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
The Advanced Recordset builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Using commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Inserting a record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Updating a record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Updating multiple records (a simple example) . . . . . . . . . . . . . . . . . . . . . 127
Deleting a record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Deleting multiple records (simple example) . . . . . . . . . . . . . . . . . . . . . . 129
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Chapter 5 Working with Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Form attributes: Action and Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
get method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
post method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Retrieving form values with Request.Form . . . . . . . . . . . . . . . . . . . . . . . . . 135
Creating sample login forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Forms with text box elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Forms with list/menu elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Menu element selection form with conditional logic . . . . . . . . . . . . . . . 138
Forms with check box elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Receiving data from a URL parameter . . . . . . . . . . . . . . . . . . . . . . . . . 141
Retrieving URL parameters with Request.QueryString . . . . . . . . . . . . . . . 141
Sending form values to e-mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Setting up your SMTP server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
ASP mail components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
General requirements for mail components . . . . . . . . . . . . . . . . . . . . 147
Sending e-mail with mail components . . . . . . . . . . . . . . . . . . . . . . . . . 148
Sending e-mail with CDO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Sending mail with AspEmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Sending e-mail with JMail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
CONTENTS
x
Dynamic e-mail interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Sending e-mail by hyperlink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Sending e-mail via a form button . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Making e-mail property values dynamic . . . . . . . . . . . . . . . . . . . . . . . . 160
Sending e-mail with dynamic values . . . . . . . . . . . . . . . . . . . . . . . . 160
Sending e-mail with dynamic form field values . . . . . . . . . . . . . . . . . . 162
Sending a page to a friend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Real-world examples using forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Sending a user a forgotten password . . . . . . . . . . . . . . . . . . . . . . . . . 167
Creating a mailing list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Chapter 6 Building a Random Quote Generator . . . . . . . . . . . . . . . 175
Creating the quotes database table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Building the form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
The Insert Record server behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Adding conditional code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
The Repeat Region server behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
The Update Record server behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
The Delete Record server behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Chapter 7 Completing the Quotes Administration System . . . . . . 195
Updating the quotes database table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Author administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Building the Insert Author page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Category administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Building the Insert Category page . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Updating the Insert Quote page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Creating the recordsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Building the Authors recordset . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Building the Categories recordset . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Building dynamic select lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Updating the Insert server behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Updating the edit page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Copying recordsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Adding authors and categories to the edit page . . . . . . . . . . . . . . . . . . . . 210
Updating the Quotes recordset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Binding dynamic select lists with a selected item . . . . . . . . . . . . . . . . . . . 211
Updating the Update server behavior . . . . . . . . . . . . . . . . . . . . . . . . . . 213
The random quote generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Creating a join in the database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Displaying a random quote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Building the Quotes recordset . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
CONTENTS
xi
Chapter 8 Restricting Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Creating the administrators database table . . . . . . . . . . . . . . . . . . . . . . . . . 224
Creating the login system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Building the login form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Adding the Log In User server behavior . . . . . . . . . . . . . . . . . . . . . . . . 227
Restricting access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Adding the Log Out User server behavior . . . . . . . . . . . . . . . . . . . . . . . 231
Registering new users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Checking the new username . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Creating a user-friendly login . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Expanding the Log In User server behavior code . . . . . . . . . . . . . . . . . . . . . . 237
Implementing the “remember me” feature . . . . . . . . . . . . . . . . . . . . . . . . . 239
Updating the login form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Baking the cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Chapter 9 Creating a Blog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Blogging application overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
The database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
The blog display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
Administrative controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Administrative login/logout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
The search function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Creating your blog database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Creating the database tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Table 1: tbl_onews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Table 2: tbl_users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
Populating the database tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
Populating tbl_onews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Populating tbl_users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Setting user permissions for tables . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Connecting Dreamweaver to your database . . . . . . . . . . . . . . . . . . . . . . . . 253
Connection strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
DSN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Displaying blog entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Creating onews_main.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Designing onews_main.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
Wiring up onews_main.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Creating onews_details.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Designing onews_details.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Wiring up onews_details.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Creating onews_archives.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Designing onews_archives.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Wiring up onews_archives.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
Blog administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Creating onews_admin_archives.asp . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Designing onews_admin_archives.asp . . . . . . . . . . . . . . . . . . . . . . . 267
Wiring up onews_admin_archives.asp . . . . . . . . . . . . . . . . . . . . . . . 268
CONTENTS
xii
Creating onews_admin_details.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
Designing onews_admin_details.asp . . . . . . . . . . . . . . . . . . . . . . . . 271
Wiring up onews_admin_details.asp . . . . . . . . . . . . . . . . . . . . . . . . 273
Securing the blog administration pages and creating login/logout functionality . . . . 276
Designing login.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
Wiring up login.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Creating logout.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Searching your blog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
Creating the search form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
Creating the results page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
Designing onews_searchresults.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
Wiring up onews_searchresults.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
Chapter 10 Image Gallery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Overview of the image gallery application . . . . . . . . . . . . . . . . . . . . . . . . . 287
Storing information in the database . . . . . . . . . . . . . . . . . . . . . . . . . . 288
Inserting, editing, and displaying albums . . . . . . . . . . . . . . . . . . . . . . . . 288
Uploading and displaying photos . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
Editing captions and deleting photos . . . . . . . . . . . . . . . . . . . . . . . . . . 288
Creating the database for the image gallery . . . . . . . . . . . . . . . . . . . . . . . . 289
Table 1: tbl_photoalbums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Table 2: tbl_photos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
The relationship between tbl_photos and tbl_photoalbums . . . . . . . . . . . . . 292
Connecting Dreamweaver to your database . . . . . . . . . . . . . . . . . . . . . . . . 294
Connection strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
Data Source Name (DSN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Inserting, editing, and displaying albums in the image gallery . . . . . . . . . . . . . . 295
Creating myphotos_main.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Designing the main web page . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Implementing the dynamic features of the main web page . . . . . . . . . . . 298
Creating addalbum.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
Designing the Add Album page . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
Wiring up the Add Album page . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
Creating edit_photo_album.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
Implementing the dynamic features . . . . . . . . . . . . . . . . . . . . . . . . 304
Creating pages for uploading and displaying photos . . . . . . . . . . . . . . . . . . . 307
Creating upload.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
Designing upload.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
Wiring up upload.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Creating upload_action.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
Creating the Edit Caption and Delete Photo pages . . . . . . . . . . . . . . . . . . 316
Creating edit_caption.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
Creating delete_action.asp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
کتاب آموزش ASP.NET 3.5 در C # 2008از تازه کار تا حرفه ایC # 2008
نویسنده: Matthew MacDonald
زبان: انگلیسی
کتاب آموزش Web Development، سیلورلایت و ASP.NET AJAX از تازه کار تا حرفه ای
نویسنده: Laurence Moroney
زبان: انگلیسی