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

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

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

gain a complete understanding of the subject, or skip around if you feel you need

a refresher on a particular topic.

Chapter 1: Introducing ASP.NET

Before you can start building your database-driven web presence, you must

ensure that you have the right tools for the job. In this first chapter, you’ll install

Visual Web Developer 2008 Express Edition and Microsoft SQL Server 2005

Express Edition. Finally, we’ll create a simple ASP.NET page to make sure that

everything’s running and properly configured.

Chapter 2: ASP.NET Basics

In this chapter, you’ll create your first useful ASP.NET page. We’ll explore all

of the components that make up a typical ASP.NET page, including directives,

controls, and code. Then, we’ll walk through the process of deployment, focusing

specifically on allowing the user to view the processing of a simple ASP.NET

page through a web browser.

Chapter 3: VB and C# Programming Basics

In this chapter, we’ll look at two of the programming languages that are used

to create ASP.NET pages: VB and C#. You’ll learn about the syntax of the two

languages as we explore the concepts of variables, data types, conditionals,

Licensed to [email protected]

xxiii

loops, arrays, functions, and more. Finally, we’ll see how the two languages

accommodate object oriented programming principles by allowing you to work

with classes, methods, properties, inheritance, and so on.

Chapter 4: Constructing ASP.NET Web Pages

ASP.NET web pages are known as web forms, but, as we’ll see, the process of

building ASP.NET web forms is a lot like composing a castle with Lego bricks!

ASP.NET is bundled with hundreds of controls—including HTML controls,

web controls, and so on—that are designed for easy deployment within your

applications. This chapter will introduce you to these building blocks and show

how to lock them together. You’ll also learn about master pages, which are a

very exciting feature of ASP.NET.

Chapter 5: Building Web Applications

A web application is basically a group of web forms, controls, and other elements

that work together to achieve complex functionality. So it’s no surprise that

when we build web applications, we must consider more aspects than when

we build individual web forms. This chapter touches on those aspects. We

configure your web application; learn how to use the application state, user

sessions, and cookies; explore the process for debugging errors in your project;

and more.

Chapter 6: Using the Validation Controls

This chapter introduces validation controls. With validation controls, Microsoft

basically eliminated the headache of fumbling through, and configuring, tired,

reused client-side validation scripts. First, we’ll learn how to implement user

input validation on both the client and server sides of your application using

Microsoft’s ready-made validation controls. Then, we’ll learn how to perform

more advanced validation using regular expressions and custom validators.

Chapter 7: Database Design and Development

Undoubtedly one of the most important chapters in the book,
Chapter 7
will prepare you to work with databases in ASP.NET. We’ll cover the essentials

you’ll need to know in order to create a database using SQL Server Express

Edition. Also in this chapter, we’ll begin to build the database for the Dorknozzle

intranet project.

Licensed to [email protected]

xxiv

Chapter 8: Speaking SQL

This chapter will teach you to speak the language of the database: Structured

Query Language, or SQL. After a gentle introduction to the basic concepts of

SQL, which will teach you how to write SELECT, INSERT, UPDATE, and DELETE

queries, we’ll move on to more advanced topics such as expressions, conditions,

and joins. Finally, we’ll take a look at how we can reuse queries quickly and

easily by writing stored procedures.

Chapter 9: ADO.NET

The next logical step in building database-driven web applications is to roll up

our sleeves and dirty our hands with a little ADO.NET—the technology that

facilitates communication between your web application and the database

server. This chapter explores the essentials of the technology, and will have

you reading database data directly from your web applications in just a few

short steps. We’ll then help you begin the transition from working with static

applications to those that are database driven.

Chapter 10: Displaying Content Using Data Lists

Taking ADO.NET further, this chapter shows you how to utilize the DataList

control provided within the .NET Framework. DataLists play a crucial role in

simplifying the presentation of information with ASP.NET. In learning how to

present database data within your applications in a cleaner and more legible

format, you’ll gain an understanding of the concepts of data binding at a high

level.

Chapter 11: Managing Content Using GridView and DetailsView

This chapter explores two of the most powerful data presentation controls of

ASP.NET: GridView and DetailsView. GridView is a very powerful control that

automates almost all tasks that involve displaying grids of data. DetailsView

completes the picture by offering us the functionality we need to display the

details of a single grid item.

Chapter 12: Advanced Data Access

This chapter explores a few of the more advanced details involved in data access,

retrieval, and manipulation. We’ll start by looking at direct data access using

ADO.NET’s data source controls. We’ll then compare this approach with that

of using data sets to access data in a disconnected fashion. In this section, you’ll

Licensed to [email protected]

xxv

also learn to implement features such as paging, filtering, and sorting, using

custom code.

Chapter 13: Security and User Authentication

This chapter will show you how to secure your web applications with ASP.NET.

We’ll discuss the various security models available, including IIS, Forms,

Windows, and Windows Live ID, and explore the roles that the
Web.config
and

XML files can play. This chapter will also introduce you to the ASP.NET

membership model and login controls.

Chapter 14: Working with Files and Email

In this chapter, we’ll look at the task of accessing your server’s file system, including drives, files, and the network. Next, the chapter will show you how to work with file streams to create text files, write to text files, and read from text

files stored on your web server. Finally, you’ll get first-hand experience in

sending emails using ASP.NET.

Chapter 15: ASP.NET AJAX

In our final chapter, you’ll learn all about the Ajax features that are built into

ASP.NET 3.5. We’ll spice up the Dorknozzle project with a few Ajax features

that’ll show how simple ASP.NET AJAX is to use. We’ll also explore the

ASP.NET AJAX Control Toolkit and see how it can enhance existing features.

Appendix A: Web Control Reference

Included in this book is a handy web control reference, which lists the most

common properties and methods of the most frequently used controls in

ASP.NET.

Appendix B: Deploying ASP.NET Web Sites

This appendix will show you, step by step, how to use Visual Web Developer

and to move your web site from your development environment to a web hosting

service and make it live on the Internet. It also covers tips for choosing a reliable

web host, ASP.NET deployment gotchas, and hints for using the SQL Server

Hosting Toolkit to migrate your database.

The Book’s Web Site

Located at http://www.sitepoint.com/books/aspnet3/, the web site that supports

this book will give you access to the following facilities.

Licensed to [email protected]

xxvi

The Code Archive

As you progress through this book, you’ll note a number of references to the code

archive. This is a downloadable ZIP archive that contains each and every line of

example source code that’s printed in this book. If you want to cheat (or save

yourself from carpal tunnel syndrome), go ahead and
download the archive.1

The archive contains one folder for each chapter of this book. Each folder may

contain a
LearningASP
folder for the stand-alone examples in that chapter and a

Dorknozzle
folder for files associated with the Dorknozzle intranet application, the

project that we’ll work on throughout the book. Each folder will contain
CS
and
VB

subfolders, which contain the C# and VB versions of all the code examples for that

chapter. Incremental versions of each file are represented by a number in the file’s

name.

Finally, a complete version of the Dorknozzle project can be found in the
Dorknozzle

folder.

Updates and Errata

No book is perfect, and we expect that watchful readers will be able to spot at least

one or two mistakes before the end of this one. The Errata page on the book’s web

site will always have the latest information about known typographical and code

errors, and necessary updates for new releases of ASP.NET and the various web

standards that apply.

The SitePoint Forums

If you’d like to communicate with us or anyone else on the SitePoint publishing

team about this book, you should join
SitePoint’s online community.2
The .NET

forum, in particular, can offer an abundance of information above and beyond the

solutions in this book.3

In fact, you should join that community even if you don’t want to talk to us, because

a lot of fun and experienced web designers and developers hang out there. It’s a

good way to learn new stuff, get questions answered in a hurry, and just have fun.

1 http://www.sitepoint.com/books/aspnet3/code.php

2 http://www.sitepoint.com/forums/

3 http://www.sitepoint.com/forums/forumdisplay.php?f=141

Licensed to [email protected]

xxvii

The SitePoint Newsletters

In addition to books like this one, SitePoint publishes free email newsletters including
The SitePoint Tribune
and
The SitePoint Tech Times
. In them, you’ll read about the latest news, product releases, trends, tips, and techniques for all aspects of web

development. If nothing else, you’ll get useful ASP.NET articles and tips, but if

you’re interested in learning other technologies, you’ll find them especially valuable.

Sign up to one or more SitePoint newsletters at

http://www.sitepoint.com/newsletter/.

Your Feedback

If you can’t find an answer through the forums, or if you wish to contact us for any

other reason, the best place to write is [email protected]. We have a well-staffed

email support system set up to track your inquiries, and if our support team members

are unable to answer your question, they’ll send it straight to us. Suggestions for

improvements, as well as notices of any mistakes you may find, are especially

welcome.

Conventions Used in This Book

You’ll notice that we’ve used certain typographic and layout styles throughout this

book to signify different types of information. Look out for the following items.

Code Samples

Code in this book will be displayed using a fixed-width font, like so:

A perfect summer's day

It was a lovely day for a walk in the park. The birds

were singing and the kids were all back at school.


If the code may be found in the book’s code archive, the name of the file will appear

at the top of the program listing, like this:

Licensed to [email protected]

xxviii

example.css

.footer {

background-color: #CCC;

border-top: 1px solid #333;

}

If only part of the file is displayed, this is indicated by the word
excerpt
:

example.css
(excerpt)

border-top: 1px solid #333;

If additional code is to be inserted into an existing example, the new code will be

displayed in bold:

function animate() {

new_variable = "Hello";

}

Also, where existing code is required for context, rather than repeat all the code, a

vertical ellipsis will be displayed:

function animate() {


return new_variable;

}

Some lines of code are intended to be entered on one line, but we’ve had to wrap

them because of page constraints. A ➥ indicates a line break that exists for formatting

purposes only, and should be ignored.

URL.open("http://www.sitepoint.com/blogs/2007/05/28/user-style-she

➥ets-come-of-age/");

Licensed to [email protected]

Other books

Sirenz Back in Fashion by Charlotte Bennardo
Undue Influence by Anita Brookner
Tiny Dancer by Anthony Flacco
White Trash Witch by Franny Armstrong
Great Sex, Naturally by Steelsmith, Laurie
Until We End by Frankie Brown
Where We Belong by Emily Giffin