Read Build Your Own ASP.NET 3.5 Website Using C# & VB Online

Authors: Cristian Darie,Zak Ruvalcaba,Wyatt Barnett

Tags: #C♯ (Computer program language), #Active server pages, #Programming Languages, #C#, #Web Page Design, #Computers, #Web site development, #internet programming, #General, #C? (Computer program language), #Internet, #Visual BASIC, #Microsoft Visual BASIC, #Application Development, #Microsoft .NET Framework

Build Your Own ASP.NET 3.5 Website Using C# & VB (4 page)

BOOK: Build Your Own ASP.NET 3.5 Website Using C# & VB
8.63Mb size Format: txt, pdf, ePub
ads

Updating a Database from a Modified DataSet . . . . . . . . . . . . . . . . . . . 543

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547

Chapter 13 Security and User

Authentication
. . . . . . . . . . . . . . . . . . . . . . . . . . . 549

Basic Security Guidelines
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
550

Licensed to [email protected]

xvii

Securing ASP.NET Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552

Working with Forms Authentication . . . . . . . . . . . . . . . . . . . . . . . . 554

ASP.NET Memberships and Roles
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
567

Creating the Membership Data Structures . . . . . . . . . . . . . . . . . . . 568

Using Your Database to Store Membership Data . . . . . . . . . . . . . . 570

Using the ASP.NET Web Site Configuration Tool . . . . . . . . . . . . . . 576

Creating Users and Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579

Changing Password Strength Requirements . . . . . . . . . . . . . . . . . . 580

Securing Your Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583

Using the ASP.NET Login Controls . . . . . . . . . . . . . . . . . . . . . . . . . . 586

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593

Chapter 14 Working with Files and Email
. . . . .
595

Writing and Reading Text Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596

Setting Up Permissions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
597

Writing Content to a Text File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600

Reading Content from a Text File . . . . . . . . . . . . . . . . . . . . . . . . . . 604

Accessing Directories and Directory Information
. . . . . . . . . . . . . . . . . .
608

Working with Directory and File Paths . . . . . . . . . . . . . . . . . . . . . . 612

Uploading Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615

Sending Email with ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619

Sending a Test Email
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
621

Creating the Company Newsletters Page . . . . . . . . . . . . . . . . . . . . 623

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633

Chapter 15 ASP.NET AJAX
. . . . . . . . . . . . . . . . . . . . . . . . . .
635

What is Ajax? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636

ASP.NET AJAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637

Using the UpdatePanel Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638

Managing the ScriptManager Control
. . . . . . . . . . . . . . . . . . . .
642

Licensed to [email protected]

xviii

Using Triggers to Update an UpdatePanel
. . . . . . . . . . . . . . . . . . . . . . . .
643

The ASP.NET AJAX Control Toolkit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 648

The ValidatorCalloutExtender Control Extender . . . . . . . . 649

Getting Started with Animation
. . . . . . . . . . . . . . . . . . . . . . . . . . .
653

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655

Appendix A Web Control Reference
. . . . . . . . . . . . . . . 657

The WebControl Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657

Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657

Methods
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
658

Standard Web Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659

AdRotator
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
659

BulletedList
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
659

Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 660

Calendar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661

CheckBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663

CheckBoxList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663

DropDownList
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
665

FileUpload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665

HiddenField
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
666

HyperLink
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
666

Image
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
666

ImageButton
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
667

ImageMap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668

Label
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
668

LinkButton . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668

ListBox
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
669

Literal
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
670

MultiView
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
670

Panel
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
671

Licensed to [email protected]

xix

PlaceHolder
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
671

RadioButton
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
671

RadioButtonList
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
672

TextBox
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
673

Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674

Xml
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
678

Validation Controls
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
678

CompareValidator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679

CustomValidator
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
680

RangeValidator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 681

RegularExpressionValidator . . . . . . . . . . . . . . . . . . . . . . . . 682

RequiredFieldValidator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682

ValidationSummary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
683

Navigation Web Controls
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
684

SiteMapPath
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
684

Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685

TreeView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690

Ajax Web Extensions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
694

ScriptManager
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
694

Timer
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
695

UpdatePanel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695

UpdateProgress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696

Appendix B Deploying ASP.NET Web Sites
. . . . . 697

ASP.NET Hosting Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697

Using Visual Web Developer Express to Deploy ASP.NET

Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698

ASP.NET Deployment “Gotchas” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701

Using the SQL Server Hosting Toolkit
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
702

Dealing with SQL Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704

Licensed to [email protected]

xx

Index
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
707

Licensed to [email protected]

Preface

Web development is very exciting. There’s nothing like the feeling you have after

you place your first dynamic web site online, and see your little toy in action while

other people are actually using it!

Web development with ASP.NET is particularly exciting. If you’ve never created a

dynamic web site before, I’m sure you’ll fall in love with this area of web development. If you’ve worked with other server-side technologies, I expect you’ll be a little shocked by the differences.

ASP.NET really is a unique technology, and it provides new and extremely efficient

ways to create web applications using the programming language with which you

feel most comfortable. Though it can take some time to learn, ASP.NET is simple

to use. Whether you want to create simple web forms, feature-rich shopping carts,

or even complex enterprise applications, ASP.NET can help you do it. All the tools

you’ll need to get up and running are immediately available and easy to install, and

require very little initial configuration.

This book will be your gentle introduction to the wonderful world of ASP.NET,

teaching you the foundations step by step. First, you’ll learn the theory; then, you’ll

put it into practice as we work through practical exercises together. To demonstrate

some of the more complex functionality, and to put the theory into a cohesive,

realistic context, we’ll develop a project through the course of this book. The project—an intranet site for a company named Dorknozzle—will allow us to see the many components of .NET in action, and to understand through practice exactly

how .NET works in the real world.

We hope you’ll find reading this book an enjoyable experience that will significantly

help you with your future web development projects!

Who Should Read This Book?

This book is aimed at beginner, intermediate, and advanced web designers looking

to make the leap into server-side programming with ASP.NET. We expect that you’ll

already feel comfortable with HTML and a little CSS, as very little explanation of

these topics is provided here.

Licensed to [email protected]

xxii

By the end of this book, you should be able to successfully download and install

Visual Web Developer 2008 Express Edition, and use it to create basic ASP.NET

pages. You’ll also learn how to install and run Microsoft SQL Server 2005 Express

Edition, create database tables, and work with advanced, dynamic ASP.NET pages

that query, insert, update, and delete information within a database.

All examples provided in the book are written in both Visual Basic and C#, the two

most popular languages for creating ASP.NET web sites. The examples start at beginners’ level and proceed to more advanced levels. As such, no prior knowledge of either language is required in order to read, understand, learn from, and apply

the knowledge provided in this book. Experience with other programming or

scripting languages (such as JavaScript) will certainly grease the wheels, though,

and should enable you to grasp fundamental programming concepts more quickly.

What’s in This Book?

This book comprises the following chapters. Read them from beginning to end to

BOOK: Build Your Own ASP.NET 3.5 Website Using C# & VB
8.63Mb size Format: txt, pdf, ePub
ads

Other books

The Captain's Lady by Louise M. Gouge
Billie Standish Was Here by Nancy Crocker
The Liar's Chair by Rebecca Whitney
Flight (Children of the Sidhe) by Pearse Nelson, J.R.
Man of the Match by Dan Freedman
Cold Grave by Craig Robertson
Better Than Weird by Anna Kerz