Skip to Content
ASP.NET 3.5 For Dummies®
book

ASP.NET 3.5 For Dummies®

by Ken Cox
February 2008
Intermediate to advanced
428 pages
8h 52m
English
For Dummies
Content preview from ASP.NET 3.5 For Dummies®

3.3. Generating a Data-Driven Web Page

Did you notice that the heading says Generating rather than Programming? In this section, VWD generates tons of code as you drag and drop.

3.3.1. Adding a single file model Web page

First, you need to create a page so you have a place for the code it creates. For this simple project (and most of the examples in this book), you use the single file model where everything goes into the .aspx page. See the "Choosing single file model or code-behind" sidebar to decide which is right for you. To add a Web page that uses the single file model, follow these steps:

  1. In Solution Explorer, right-click the project name, and then choose Add New Item.

  2. In the Add New Item window, select the Web Form template.

  3. Type default.aspx as the name of the file.

  4. Clear the check box for Place Code in Separate File.

    This ensures that the IDE puts all code within the .aspx file.

  5. Click Add.

    The new, empty page appears in the IDE.

3.3.2. Using the database to build a Web page

Instead of adding controls to the page from the Toolbox, let the IDE do the work. You need a SQL Server database (Express is fine) for this magic. I show you how to create the database in the previous section, "Using a SQL Server Express Database." To generate a user interface based on a database table, follow these steps:

Choosing single file model or code-behind

ASP.NET allows you to keep both the HTML and Visual Basic (or C#) source code in one file that uses the .aspx extension. The other option is ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET 3.5 Unleashed

ASP.NET 3.5 Unleashed

Stephen Walther
ASP.NET 4 Unleashed

ASP.NET 4 Unleashed

Stephen Walther, Kevin Hoffman, Nate Dudek

Publisher Resources

ISBN: 9780470195925Purchase book