Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

ASP .NET Web Developer s Guide - Mesbah Ahmed, Chris Garrett

.pdf
Скачиваний:
37
Добавлен:
24.05.2014
Размер:
7.32 Mб
Скачать

660 Chapter 13 • Creating a Message Board with ADO and XML

Designing the Browsing Interface

;Create the Board browsing. Create the Web Form and use the Repeater control and DataBind it to a DataSet.

;Create the Thread browsing. Create the Web Form and use the Repeater control and DataBind it to a DataSet.

;Create the Post browsing. Create the Web Form and use the Repeater control and DataBind it to a DataSet.

Creating the User Functions

;Generate the Thread creation. Create the Web Form and use Validation controls and text boxes to get the necessary information.

;Generate the Post creation. Create the Web Form and use Validation controls and text boxes to get the necessary information.

Building the Administrative Interface

;Create the interface to ban and promote users. Make sure only administrators can access this functionality using the properties built into the FormBase class.

;Create the interfaces necessary to delete Board,Thread, and Post pages. Modify the existing View Board,Thread, and Post pages to create the links to the delete pages.

;Create the interfaces necessary to edit Posts. Modify the existing view Post page to create the links to edit Posts.

www.syngress.com

Creating a Message Board with ADO and XML • Chapter 13

661

Frequently Asked Questions

The following Frequently Asked Questions, answered by the authors of this book, are designed to both measure your understanding of the concepts presented in this chapter and to assist you with real-life implementation of these concepts. To have your questions about this chapter answered by the author, browse to www.syngress.com/solutions and click on the “Ask the Author” form.

Q:When designing applications, do I need to design them in an ObjectOriented manner?

A:Absolutely not, although when applications are designed in an OO manner, they are typically more scalable and maintainable, and allow for the use of multiple User Interfaces.You are not forced to create applications in an OO manner, but good programming practices typically stress Object Orientation.

Q:Are there any performance issues when using an OO approach versus a more procedural approach?

A:Yes, typically the OO approach adds a bit of overhead to everything you do. For instance, the creation of the custom DataSet in order to view Boards, Threads, and Posts spends extra time that wouldn’t have been lost if you had gone directly to the database instead of accessing the data through objects. The price of scalability and maintainability is a possible performance loss. Luckily, with .NET, execution is very fast after the initial compile, so it’s also very likely that you would never notice the speed loss.

Q: How important is it to use Validation controls?

A:Very important. In ASP 3.0 and 2.0 (heck, even ASP 1.0), all validation had to be done by hand. Empty fields needed to be validated as well as e-mail addresses and URIs.With Validation controls, ASP.NET does all of this for us, allowing us to focus more on the logic and business rules in our application.

www.syngress.com

662Chapter 13 • Creating a Message Board with ADO and XML

Q:How can I ban a list of IP addresses in the future?

A:First, you would need to create a table in your database to store the list of IP addresses, and provide a way for an administrator to enter an IP address into it.Then, at every page you want to disallow this list of IP addresses from viewing, compare the IP address of the requesting user and compare it to the list of IP addresses you have banned. If it exists in your list of banned addresses, redirect them to another page or do whatever else you feel is appropriate.

www.syngress.com

@ OutputCache directive, usage, 269–277, 279

A

absoluteExpiration, 258 Accept-Language

header values, 274 parameter, 274

Access control, authorization tag (usage), 208–209

Access database, creation, 506–509 Access datatype, 510

Access object, creation. See Data Access times, 267

Account element, 393 Accounts element, 385, 386 Action events, 77

Active Server Pages (ASP). See Classic ASP

applications, 87

ASP.NET applications, contrast, 231 ASP 1.x, development, 5–6

ASP 2.x changes, 6–7

development, 6–7 weaknesses, 7

ASP 3.0 development, 7–9 weaknesses, 8–9

code, 12

control declaration, 483 controversy, 4–5 developers, 78, 130 editing environment, 5 Engine, 62, 76

file execution,Web server usage, 15–27 history, 2–11

Index

model

ASP.NET improvements, comparison, 14–15

need, 9 need, 3–4

original model, changes, 8 origins, 2–5

pages, 86, 161 scripts, 576

skills, obsolescence, 86 timeline, 10–11 upgrading. See Classic ASP version 4, 11

ActiveX controls, 164, 167 ActiveX Data Objects (ADO), 6, 8

ADO-related codes, 86 update, 19

usage. See Message board creation version 2.5, 10

Actual comment, 475 add attribute, 203

add (processing directive), 189 Add stored procedure, 335

add subtag, 190, 192–193, 202, 207 add tag, 616

addBook page, 533 addBook.aspx, creation, 543

addBook.aspx, creation. See addBook page

addCat, 528, 530

Address book application, creation, 314–341

Address.aspx, 314 AdminAddBook, 512 AdminAddCat, 512 AdminAddCustomer, 512 adminCustomer, 518

663

664 Index

AdminDeleteBook, 512

AdminDeleteCat, 512 AdminDeleteCustomer, 512

Administration login (adminLogin.aspx), creation, 535–536

Administrative interface, construction. See Message board creation

Administrator page (adminPage.aspx), creation, 537–543

Administrators, 581. See also Logged-in administrator

adminLogin.aspx, creation. See Administration login

adminPage.aspx, creation. See Administrator Page

AdminUpdateBook, 512

AdminUpdateCat, 512 AdminUpdateCustomer, 512 ADO. See ActiveX Data Objects ADOCatalog, creation, 547–553 ADO.NET, 12

ADO contrast, 53

changes, understanding, 300–310 FAQs, 345–346

introduction, 299, 300 solutions, 343–344 supported connectivity, 305

ADO.NET shopping cart creation, 501

database, setup, 502–518 FAQs, 566 introduction, 502

site

administration, 533–547 construction, 533

solutions, 562–565 AdRotator controls, 62 ADSI, 13

allBooks.addItem Web method, creation, 541

AllCustById, 512

Allow Paging property, 144

allowOverride attribute, 174, 176, 177, 214

AllowPaging, 152 AllowSorting property, 144, 150

AlternatingItemStyle property, 147 AlternatingItemTemplate, 132

Anchor tag. See HyperText Markup Language

Application. See ASP.NET application cache object, 233–234

class, 250 configuration, 179–184

creation. See ASP.NET application design. See Message board creation events

support, 236–237 usage, 236–239

identity configuration, identity tag (usage), 181

locking, 239

log,Trace information (writing), 432

testing/error-checking. See ASP.NET application

tracing, 432–434 variables, 229, 234 Application state, 63

session states, comparison, 246–258 understanding, 232–236

usage, 232–234 Application-level trace, 433 Application-level variable, 547 Application_onstart method, 548

Application-specific configuration section handlers, 212

Application-wide issues, 246

ApplyStyles, 620

AppSettings, 620 appSettings

node, 312

tag, usage, 220. See also Static variables ArgumentException, 586, 587, 599 Ariba, 350, 455

Array class, 44

Array-like addressing, usage, 96 ArrayList, 95, 602

ListControl, binding, 111–113

.ascx file, 163

.asmx

.aspx, contrast, 450–451 file, 445

extension, 450 page, 444

ASP. See Active Server Pages asp:Button, 62, 135 ASPError object, removal, 27 asp:Label, 62, 102

control, 162 ASP.NET

browser capability function, 21 controls, 68

delivery, 18 developers, 46 Engine, 66 FAQs, 32–33

flexibility, utilization, 12–14 framework, 69

improvements, comparison. See Active Server Pages

introduction, 2 object, 47

pages, 51. See also Data-enabled ASP.NET pages

compilation, 18, 37

Index 665

platform basics, review, 11–15 scripts, 15

server controls, display. See Netscape 4.x

server-side processing, 65 solutions, 29–31 techniques, 95

ASP.NET application, 37, 227 contrast. See Active Server Pages copying, 613

creation, 20–26, 229 debugging, 27 deployment, 13 FAQs, 262–263 introduction, 228 solutions, 259–262

testing/error-checking, 235–236 understanding, 228–229

ASP.NET configuration, 173 FAQs, 224–225 introduction, 174 overview, 174–177 solutions, 223–224

ASP.NET debugging, 417 FAQs, 439–440 introduction, 418 solutions, 438–439

ASP.NET Web application, 86 controls, 66

form, structure, 75–76 pages, running, 19–26

asp:RequiredFieldValidator server control, 535

asp:requiredfieldvalidator tag, 536 asp:TextBox, 62

.aspx

contrast. See .asmx

666 Index

extension, 65 file, 77, 314, 478

scripts, inclusion, 69–72 page, 451

ASPX code, 488 ASPX page, 65, 162

asp:XML server control, 553 asp:xml server control, 547 ATG, 7

Attribute name, 355 AttributeCount property, 365 Attributes, 353

Authentication, 204. See also Biometric authentication;Windows authentication

cookie data, encryption/decryption. See Forms

modules, removal, 207 authentication tag, 205, 206

usage. See User authentication

authenticationModules tag, usage. See Security

authorization tag, usage. See Access control

AutoGenerate, usage, 209

AutoGenerateColumn property, 144, 147

Automatic drill-down facilities, 387 AutoNumber, datatype, 508 AutoPostBack

attributes. See Server controls property, 85, 106

B

B2B partners, 361

BackColor, 101

Backend database failure, 208

Back-end databases, 3

Back-end Web programming, 5 bin subdirectory, 78, 81, 106

Binary code, 18. See also Machinespecific binary code

bindDataGrid procedure, 152 routine, 150

Binding, usage. See Data bindListControl sub-procedure, 131 Biometric authentication, 207 BK_Author, 505

BK_Description, 505

BK_ImagePath, 505

BK_ISBN, 505, 506

BKOR_Price, 506 BKOR_Quantity, 506 BK_Price, 505 BK_Title, 505

Board

browsing, 628–638 class, design, 591–612 object, 592, 657

BoardDescription, 569

BoardID, 569, 570, 596 BoardName, 569, 570, 612 /body, 130–161

Body field, 608

Book Shop Web services, overview, 518–520

BookCatalog class, creation, 548–553 bookCatalog method, 553 bookCatalog.catalogItemDetails, 555 Books

addition. See Database deletion, 541–542 details, updating, 542–543

bookSourceUI, 548 Booleans, 38, 40

BorderColor, 101 bordercolor property, 122 BorderStyle, 101 BorderWidth, 101 Borland, 14 Bottom-most nodes, 360 BoundColumn, 147

Breakpoints, setting, 434–435 Broadvision, 7

Browser. See Down-level browsers; Up-level browsers

communication. See Client/browser communication

type, 16

Browser-based state solution, 230

browserCaps tag, usage. See Client capabilities determination

Browser-compliant HTML, 75 Browsing interface, design, 628–638 btnEditPost_Click method, 657 btnRegister_Click subroutine, 623 btnUpdate_Click method, 640 Bug fixes, 300

Built-in applications, 25 Built-in features, 62 BulletList, 123

Business objects, 568 Byte data types, 39

C

C, 3, 447 programmers, 24

C#, 9, 11–13, 26, 247, 450 class file, 78

source file, 79, 81 syntax, 24, 248 usage, 20, 79, 82

Index 667

Web Service, 522

C++, 3, 8, 14, 25, 447. See also Visual C++

ATL

code, 578 COM, 578

bolted-on approach, 11 C# .NET, 306

Cache duration, 280 expiration, 258

method, usage, 282–284 object. See Application optimization, 268–269 values, 234

Cache Insert method, 258

cache.add method, usage, 282, 285–292 Cached configuration, 220 Cache-filling statements, 258

cache.insert method, usage, 282, 285–292

CacheItemPriority setting, 289 CacheItemPriorityDecay setting, 289 CacheItemRemoved option, 290

CacheItemRemovedCallback delegate, usage, 289–292

Cache.Remove method, usage. See /HTML

Caching, 273. See also Data; Fragment caching; Output caching

data, 282 facility, 252

implementation, 293 overview, 266–269 uses, 293–294

Caching methods, optimization, 265 FAQs, 297–298

introduction, 266

668 Index

solutions, 296–297 Calendar controls, 62 Camel-cased attributes, 211 Carriage return, 24

Cascading Style Sheet (CSS), 348 code, 62

file, 617 script, 491 styles, 622

Case sensitivity, 355 Catalog

element, 353 method, creation, 550 node, 360

rendering, 558–559

catalogByCategory method, creation, 550–551

catalogItemDetails method, creation, 550

catalogRange method, creation, 550–551

catalogRangeByCategory method, creation, 551–553

Catalog.xsd, 358 Catch statements, 425 CAT_ID, 504–505, 522 CAT_Name, 505

C-compiled languages, 5 CDalAddress class, 319

CGI. See Common Gateway Interface Change events, 77

Char data type, 40 CheckBoxes, usage, 103–106 CheckBoxList, 108

control, 101, 106 Child node, 360 Child objects, 597 ChildControls, 621 ChildNodes, 373

ChildNodes.Count, 373 ChildPost property, 599, 603, 605 ChildPosts property, 599, 603, 605 ChildThread, 594

Class file, compiling, 78 Class viewer, usage, 436–437 Classes, 464

arrays, 464–465 Classic ASP, 14, 17, 22

pages, 37 projects, 24 upgrading, 26–27

ClassViewer, 437 clear attribute, 203

clear (processing directive), 189 clear subtag, 190, 192–193, 202, 207 Clear (value), 206

click() event, 70

Client capabilities determination, browserCaps tag, usage, 184–186

Client/browser communication (enabling), System.Web namespace (usage), 45–52

supplied functionality, 45–52 Client-server interaction, 16–17 Client-side JavaScript validation, 120 Client-side scripts, 75

Client-side validation, 120, 121 function. See CustomValidator

ClientValidationFuncation property, 121 C-like shorthand, 250

CLR. See Common Language Runtime cmdCompute, 164

cntApplication, 250 COBOL.NET, 13 Code

conversion. See Multiple languages

creation. See eXtensible Markup Language Cart

development activities, 78 listing, 328

Code-Behind, 63, 78 attribute, 82

class file, development, 83 file, 312

Code-behind, 106, 635, 650, 657 classes, 66, 181

in-page coding, contrast, 77–87 onsubmit(), 559

pages, 15, 450, 455, 543 usage

compilation, inclusion, 81–84 compilation, non-inclusion, 79–81

CodeBehind.aspx file, 80 ColdFusion, 7 Collection objects, 111

Colors, manipulation, 491–495

Column mapping, usage. See DataGrid control

COM. See Component Object Model COM+ components, 27

Command object, 325, 328, 332, 335 usage, 337

Command-line tools, 12 CommandSource, 136

Comment, 352. See also Actual comment Common Gateway Interface (CGI), 4

programs, 3

Common Language Runtime (CLR), 11–13, 27, 37, 63

CLR-supported language, 75 Intermediate Language (IL), 447 languages, 300

usage, 45, 75, 313

Index 669

Common Object Request Broker Architecture (CORBA), 443, 448

CompareValidator, 113, 127–128, 535 control, 117–118

Compilation command, 81 errors, 418–420

inclusion/non-inclusion. See Codebehind

options (setting), compilation tag (usage), 187–190

compilation subtags, 189

compilation tag, usage. See Compilation compiler subtag, 188

Compiling. See World Wide Web services

complexType data structures, 357–358 Component Object Model (COM), 6

components, 24, 27 foundations, 9 objects, 8, 231, 576

Comprehensive Perl Archive Network (CPAN), 5

comptePay procedure, 166 configSections tag, 212

Configuration. See Application; ASP.NET configuration; Encryption; HyperText Transfer Protocol; Request; Security; Session state; Sessions; System; World Wide Web

file, 174

anatomy, 211–222 creation, 215–219 overriding, 175 uses, 177–211

hierarchy, 176 inheritance, 176 section handlers, 212