Free Programming Books
Free download ebooks on computer and programming | |||
Free Ebook "Programming the Web with Visual Basic .NET" Sample Chapter
Programming Web w/ VB.NET
Download chapter
Free download Chapter 15: Creating a Web Site Programming the Web with Visual Basic .NET is a comprehensive guide to building web applications and services using Visual Basic .NET. It is written especially for experienced Visual Basic programmers who use Visual Studio .NET for their development work, even those who have never written a web application before. Because the .NET Framework simply blows away the archaic tools previously available to web programmers, the authors predict that many Visual Basic programmers who successfully avoided Web programming in the past will now bring their expertise to the Web. However, even experienced web programmers will greatly benefit from the authors' thorough coverage of the ASP.NET namespaces and their clear coverage of the ADO.NET classes most important to Web applications that use relational databases for data storage. All developers will benefit from the authors' extensive practical advice (based on their unique professional backgrounds) about how to produce create high-quality code and how to create professional, usable websites. After reading Programming the Web with Visual Basic .NET, you'll understand how to build and deploy top-quality, professionally designed, highly usable web applications using Visual Basic .NET. Creating a Web SiteTHE EARLIER CHAPTERS in this book presented a wealth of ASP.NET features and tools that you can use to create effective Web sites. In this final chapter, we show how to put many of those features and tools to use to create a professional-quality Web site. In your capacity as a Visual Basic .NET Web programmer, you may well find yourself collaborating with a professional Web designer. (We're talking about a person here, not a software program!) In all likelihood, that designer will not be using Visual Studio .NET. Don't worry about it. In this chapter, we explain how to take the HTML design created using a different tool-in this case Microsoft FrontPage, but it doesn't really matter-and implement the design in Visual Studio .NET. Here we also address the factoring of a Web application into controls and other useful classes. As with all Visual Basic .NET programming, doing a good job of factoring improves the reliability and maintainability of your code. By encapsulating all access to a database within a particular class, for example, you eliminate redundant code and make it possible to incorporate database changes and improvements reliably and efficiently. To enhance scalability, the database classes in this chapter make extensive use of stored procedures and data readers. As we demonstrate, Visual Studio .NET makes it easy to create and use stored procedures with data readers. In earlier chapters, we focused on securing sensitive Web information through authentication and authorization provided by IIS and ASP.NET. But your Web site can make use of a visitor's identity for other purposes as well. In this chapter, we show how to use persistent cookies to personalize a Web site. If you create a public Web site, you'll want to make sure that potential visitors can find it. Most surfers use major search engines to locate Web sites of interest to them, and so we conclude this chapter by showing how to make your Web site accessible to search engines. Working with a Professional DesignerTo make our discussions concrete, we present a case study in this chapter that builds an ASP.NET Web application from a design created in Microsoft FrontPage. The VB Snippets Web site resembles the Web application we used to illustrate the material in the last two chapters, but it has a more professional appearance and includes more usability features. As a matter of fact, the earlier versions of this Web application served as a prototype for the case study. The VB Snippets case study contains many Web pages and a lot of code. In this chapter, we present some of the code, but only to illustrate points not made in earlier chapters. We encourage you to download the code and experiment with it yourself to see how all of the pages in the Web site work together. The code includes scripts to set up the databases used by VB Snippets, plus another Web application that we used to add and edit the code snippets displayed by the case study. Figure 15-1 shows a collage of the Web pages that we used to maintain the VbCode database. As this application closely resembles code presented in Chapter 13, we don't discuss it further in this chapter. The VbCode database stores the code snippets and localized descriptions for each. The case study supports five languages: English, Spanish, French, Portuguese, and German. Visitors to the VB Snippets Web site locate the snippets they wish to see (and copy) using keywords associated with each snippet. Figure 15-2 shows a diagram of the VbCode database in the SQL Server Enterprise Manager. All of the accesses to this database in the VB Snippets case study occur through a single class file that's discussed later in this chapter. One of the advantages of collaborating with a professional designer is that you can work concurrently. Using simple prototype Web pages, you can create and test classes that you will use when you implement the Web application after the design is completed. You can also create and populate test databases to use to test both the prototypes and the finished Web application. Overlapping the work in this manner allows you to improve the delivery time of a Web application significantly. Like programming, Web site design is an intense, exacting occupation. And, again like programming, the design of a good Web site takes time and effort. Fortunately, Visual Studio .NET makes it possible to prototype a new Web application while its design is in progress. The prototyping period is an excellent time to establish a good working relationship with the professional Web site designer on your team. Establishing a Working RelationshipBecause of the newness of ASP.NET, Visual Basic .NET programmers and Web site designers are still formulating their working relationships. Each organization will, no doubt, create procedures to reflect its unique requirements. Over time, we predict, Web design tools will integrate nicely with Visual Studio .NET, but you don't have to wait for that day. As we demonstrate in this case study, you can quite productively build an ASP.NET Web application from a design that was created using a tool other than Visual Studio .NET. Why won't your professional Web site designer be using Visual Studio .NET? Although Visual Studio .NET offers a fine development environment for programming, other tools have been created specifically for the purpose of creating the HTML, images, and JavaScripts used for Web sites. Until Visual Studio .NET matches those capabilities, Web site designers will-understandably-use the tools that are familiar to them. Even when Visual Studio .NET does match those capabilities, many Web designers will stick with the tool they know rather than switch to something new. Irrespective of their choice of tools, however, good Web designers provide great value to a Web development project. A good Web designer combines an artistic sense with a hard-earned knowledge of the variations in popular Web browsers and is well versed in usability issues. Because it is surprisingly difficult to create HTML that displays attractively in many browsers, good Web designers work meticulously, sometimes to the point of inserting single pixels, to make their designs look right in as many browsers as possible. Just as it is very difficult to create a good cross-browser design, it is correspondingly easy to mess it up. Even things that should not, in theory, make any difference to a browser sometimes do. As programmers, we are used to seeing code nicely indented, and the authors of this book like to see HTML nicely indented also. All of the HTML examples in this book use indentation to help reveal the nested structure. Nevertheless, "fixing" HTML by indenting it nicely sometimes causes it to display incorrectly in one or more browsers. Perhaps the biggest step a programmer can take in creating a good working relationship with a professional Web designer is to respect the design delivered: avoid making any unnecessary changes to the HTML, and consult with the designer on all changes. | |||