Chapter 14: Developing Database Web Applications using ASP.NET


As the programming world moves toward the Internet these days, it's becoming important for developers to be able to create Web applications and Web services. The Microsoft .NET Framework enables you to develop, maintain, and deploy reliable and high-performance Web applications and Web services.

This chapter starts with an overview of ASP.NET and how to install it, followed by a simple Web application development using Visual Studio .NET (VS .NET). After that it discusses the Web Forms controls and how to use them. The Web Forms' DataGrid control is a useful control to develop Web-based database applications. You can bind a DataSet to the DataGrid control as did for a Windows Forms' DataGrid control. This chapter also discusses how to fill data to a DataGrid and how to develop powerful Web-based database applications using the DataGrid control. It also discusses how to enable paging in a DataGrid control. At the end of the chapter you'll see how to develop a guest book for your Web site using ASP.NET.

Introducing ASP.NET

Writing database Web applications using ADO.NET in VS .NET is similar to writing Windows applications. The Microsoft .NET Class Library provides a set of server-side controls, which you can treat as Windows controls. To create a Web application, all you have to do is create a simple project, drag server-side controls onto a Web form, set their properties, and write event handlers. In this chapter, you'll first develop a simple Web application and see how the ASP.NET model works with Visual Basic .NET (VB .NET) and other .NET languages. After that you'll concentrate on ASP.NET and see how to write some real-world database Web applications using ADO.NET and VB .NET.

ASP.NET Platform Requirements

The following operating systems support ASP.NET: Windows XP, Windows 2000 Server, and Windows NT 4 (running Service Pack 6a) with Internet Information Services (IIS) 4 or later. Also, you must have the .NET Software Development Kit (SDK) installed on the server.

ASP.NET Language Support

You can use any .NET-supported language to write ASP.NET applications, including C#, VB .NET, and JScript. As this book is about VB .NET, the other languages are beyond the scope of this book.

Installing ASP.NET

You can develop and run ASP.NET applications on Windows 2000 or Windows XP operating systems. ASP.NET ships with VS .NET. For developers who don't have VS .NET, ASP.NET comes in a separate package, which can be downloaded from the Microsoft's Web site (www.microsoft.com). If you want to develop ASP.NET mobile-enabled applications for Pocket PC or cellular phones, you need to install ASP.NET Mobile Internet Toolkit, which you can also download from Microsoft Web site.

ASP.NET Editors

We'll be using VS .NET to develop the applications in this chapter. However, like most languages in the .NET family, you can develop ASP.NET applications using any text editor and command-line compiler. After compiling, you copy your file manually to IIS to deploy the application. The advantage of using VS .NET is that it provides you with a visual Integrated Development Environment (IDE) to drag and drop controls onto a page and view the Hypertext Markup Language (HTML) code in an HTML editor. Other features are IntelliSense and syntax checking. In summary, you can use VS .NET to compile, debug, and deploy your application.

Note

ASP.NET editors, including VS .NET, provide What-You-See-Is-What-You-Get (WYSIWYG) support for developing Graphical User Interface (GUI) applications by dropping controls on the Web Forms pages.

Microsoft has also released a lightweight, easy-to-use, and free ASP.NET development tool (including editor) for non-VS .NET developers. You can find more details about this tool on the www.asp.net Web site.

ASP.NET: An Evolution of ASP

ASP.NET, previously called ASP+, is not just the next version of ASP. It is a new programming model based on Microsoft's .NET Framework for developing Web applications. Although ASP.NET syntaxes are taken from ASP, the ASP.NET model takes full advantage of Microsoft's Common Language Runtime (CLR) and its services. Therefore, developers have the flexibility to choose any .NET-supported language to write ASP.NET applications.

The main advantages of the ASP.NET model are the following:

  • ASP.NET is simple and flexible: Developing ASP.NET applications using VS .NET is similar to developing Windows applications. VS .NET offers you a set of controls to use with ASP.NET. You just need to drag and drop the controls onto a Web Form, write events corresponding to the controls, and compile and run the program. Other features include simple client authentication, security, deployment, and site configuration.

  • ASP.NET is language independent: You can choose any language that supports .NET, including C#, VB, VBScript, and JScript.

  • ASP.NET supports data binding: ASP.NET offers you a set of data-binding controls such as the DataGrid, DataList, and others. You can bind data with these controls in a similar fashion as you do in any Windows Forms application.

  • ASP.NET has enhanced performance and scalability: ASP.NET code is not interpreted like traditional ASP pages. ASP.NET pages are compiled on the server in a .NET assembly. It takes advantage of early binding, just-in-time compilation, native optimization, and caching services. ASP.NET also works in clustered and multiprocessor environments.

  • ASP.NET is browser independent: If you ever programmed in previous versions of ASP, you've probably had problems running ASP pages in browsers other than Internet Explorer. ASP.NET is browser independent. It automatically checks what browser you're using and produces HTML at runtime accordingly.

Web Forms and Web Services

Web Forms is a term Microsoft introduced when it released its ASP+ framework for developing Web applications using the ASP model.

Similar to Windows applications and services, you can also write Web applications and services. A Web application is a distributed application, which allows you to work and distribute functionality over the Web and provides user interfaces. Using Web Forms controls, you can write Web GUI applications similar to Windows applications.

ASP.NET's Web Forms provide you with the ability to build Web-based GUI applications. Web Forms include Web pages (also called ASP.NET pages or Web Forms pages) and GUI components (sometimes called server controls) such as a TextBox, Button, ListBox, DataGrid, and so on. ASP.NET provides the flexibility to add these controls to an ASP.NET page at runtime as well as at design-time. VS .NET provides design-time features to develop applications in no time. You add controls to a page by dragging controls from the Toolbox to the page and then setting the controls' properties and events. Web Forms also provide a method for using the Codebehind directive to separate your data from the code. In other words, you can write code in a separate file from the controls.

Web services are applications that perform a certain task; they can be used by a single application as well as distributed on the Web. However, Web services don't usually have a user interface like a normal application would. Chapter 15 covers Web services.




Applied ADO. NET(c) Building Data-Driven Solutions
Applied ADO.NET: Building Data-Driven Solutions
ISBN: 1590590732
EAN: 2147483647
Year: 2006
Pages: 214

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net