1 / 41

Chapter 6

Chapter 6. INTRODUCTION TO ASP.NET. Objectives. In this chapter, you will: Learn about the .NET framework, ASP.NET, and .NET server controls Become familiar with the .NET class libraries Learn how to create Web application projects

lola
Download Presentation

Chapter 6

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 6 INTRODUCTION TO ASP.NET Database-Driven Web Sites, Second Edition

  2. Objectives In this chapter, you will: • Learn about the .NET framework, ASP.NET, and .NET server controls • Become familiar with the .NET class libraries • Learn how to create Web application projects • Learn how to use the Visual Studio .NET integrated development environment to create and manage Web application projects Database-Driven Web Sites, Second Edition

  3. Objectives In this chapter, you will: • Learn how to create and modify Web application project components • Learn how to access and reference Web forms • Learn how to move a Web application project's files to a different physical folder Database-Driven Web Sites, Second Edition

  4. The .NET Framework • Web application: one or more files that developers create to solve a problem or provide a service through a Web site • .NET framework: a set of code, objects, and standards for building computer applications Database-Driven Web Sites, Second Edition

  5. The .NET Framework • Programs can be created within the .NET framework using Visual Basic, Visual C++, C#, and JScript languages • When a .NET program is created using any of these languages, the code is compiled into a common intermediate language called the Microsoft Intermediate Language (MSIL) • The Common Language Runtime (CLR) application runs the MSIL program Database-Driven Web Sites, Second Edition

  6. The .NET Framework • .NET framework • All elements are objects • Defines objects using a standard set of programs that are called class libraries • ASP.NET: set of class libraries containing code that defines objects used to create Web applications • Web application project: contains all the related files in a Web application Database-Driven Web Sites, Second Edition

  7. Introduction to ASP.NET • ASP text file • Has an .asp extension • Contains ASP server-side script commands interleaved with HTML tags, Web page elements, and client-side script commands • ASP had a number of limitations • To address these, Microsoft developed ASP.NET pages, which are also called ASPX pages or Web forms • Web form: text file with an .aspx file extension that contains Web page elements Database-Driven Web Sites, Second Edition

  8. An Overview of ASP.NET Server Controls • HTML designers: responsible for the HTML components of an application • Web programmers: responsible for the program components, such as the client-side scripts and server-side programs • Server control: • An element that an HTML designer creates in a Web form • Provides a more direct link between items on a Web page and programs running on the Web server Database-Driven Web Sites, Second Edition

  9. An Overview of ASP.NET Server Controls • Server controls: • Have associated events that the Web server associates with user actions • Enable Web developers to create modular Web applications • Server-side event handler: contains program commands that respond to events that the user raises on Web server controls Database-Driven Web Sites, Second Edition

  10. An Overview of ASP.NET Server Controls • The HTML tags, elements, and Web server definitions exist in the Web form’s .aspx file • Commands that reference the Web server controls exist in a separate VB .NET program file • Main types of ASP.NET server controls: • Rich server controls • HTML server controls • Validation server controls Database-Driven Web Sites, Second Edition

  11. The .NET Framework Class Libraries • The .NET framework is built on the object-oriented model • Object class: defines the properties and actions of similar objects • Class: defined by its properties, events, and methods • Object classes usually have a hierarchical structure that defines parent classes and child classes Database-Driven Web Sites, Second Edition

  12. The .NET Framework Class Libraries • The .NET framework defines all of its elements using similar object classes, which are called namespaces • Figure 6-6 shows the ASP.NET namespace hierarchy Database-Driven Web Sites, Second Edition

  13. The .NET Framework Class Libraries • The .NET framework arranges its namespaces hierarchically using parent and child classes • Dot syntax is used to reference child classes within parent classes: parent_class.child_class Database-Driven Web Sites, Second Edition

  14. Creating a Web Application Project • Visual Studio .NET can create and configure Web application projects allowing developers to manage and control all of the application files • When a new Web application project is created in Visual Studio .NET, the IDE automatically creates a project folder in a physical directory • Visual Studio .NET also automatically creates a Web server application that it associates with the project folder Database-Driven Web Sites, Second Edition

  15. Configuring the Web Server for Web Application Projects • Application root: Web server application whose associated folder contains the project folders for the Web application projects that are being created • To configure the application root, a Web server application must be created and associated with every folder in the folder path to the application root Database-Driven Web Sites, Second Edition

  16. Creating Web Application Projects • Project: consists of multiple files that comprise a Web application • Project files: • Solution: consists of one or more projects • Global files: visible to all project components • Resource files: data that supports the project • Project files: contain information about the project structure and contents Database-Driven Web Sites, Second Edition

  17. Creating Web Application Projects • A project consists of one or more Web forms • Each Web form has an associated code behind file, containing code that Web developers create to interact with the Web form’s server controls • By default, Visual Studio .NET places all new project folders in the default Visual Studio Projects folder Database-Driven Web Sites, Second Edition

  18. The Visual Studio .NET Integrated Development Environment Database-Driven Web Sites, Second Edition

  19. The Visual Studio .NET Integrated Development Environment • The main Web application project IDE windows include: • Solution Explorer Window: lists the Web application project components • Web Browser Window: displays the design area and code window for the project's Web forms • Toolbox: used to add elements to a Web form such as rich server controls, HTML server controls, and HTML elements • Properties Window: lists the properties of the object that is currently active Database-Driven Web Sites, Second Edition

  20. The Solution Explorer • When a Web application project is created or opened in Visual Studio .NET, the Solution Explorer displays the project and its components as a hierarchical tree • This tree contains a node to represent each open project, and nodes below the project to represent the project components • The Solution Explorer window is used to add and remove project items Database-Driven Web Sites, Second Edition

  21. The Web Browser Window • The Web Browser Window: where you create and view HTML documents and write code for client-side scripts • Displays Web forms in Design view and HTML view • Design view shows the form and its components visually • A grid appears on the Web form display in the Web Browser Window • This grid is used to align form objects Database-Driven Web Sites, Second Edition

  22. The Web Browser Window Database-Driven Web Sites, Second Edition

  23. The Toolbox • To add rich server controls, HTML server controls, and HTML elements to a Web form, a developer can select a tool in the Toolbox and draw the associated control on the Web form in Visual view Database-Driven Web Sites, Second Edition

  24. The Toolbox • Toolbox: contains tools to create controls and other objects on Web forms • Default Toolbox tabs: • Data • Web Forms • Components • HTML • Clipboard Ring • General Database-Driven Web Sites, Second Edition

  25. The Properties Window • Properties Window: lists the properties and their current design time values for the project component that is selected in the Solution Explorer or for the Web form item that is selected in the Web Browser Window in Visual view • Categorized button: shows the property names under nodes that represent different property categories Database-Driven Web Sites, Second Edition

  26. The Properties Window • Alphabetic button: shows properties in an alphabetized list • Property Pages button: opens a dialog box containing tab pages that allow the developer to set property values Database-Driven Web Sites, Second Edition

  27. Working With Project Components • HTML designers use Web form controls and other Web page elements to create the visual elements that appear on a Web page • After creating a Web form control, you can modify the control’s properties to specify how the control looks and behaves when the form first opens • Then you can write the code behind the controls to modify control properties at run time and perform server-side processing Database-Driven Web Sites, Second Edition

  28. Creating Web Form Controls • To create a rich server control on a Web form, the desired control is selected in the Visual Studio .NET Toolbox, dragged onto the form in Visual view, and then repositioned and resized Database-Driven Web Sites, Second Edition

  29. Creating Web Form Controls • Web forms: uses a grid layout style so that Visual Studio .NET specifies the element’s location on the form using an absolute position • Absolute position: element’s location from top left using values in the element’s style tag Database-Driven Web Sites, Second Edition

  30. Modifying Web Form Properties • To change a control’s design time property values: • Control is selected in the Browser Window • Property values are changed in the Properties Window • ID property: specifies how the Web form internally references the control • Every Web form control must have a unique ID value Database-Driven Web Sites, Second Edition

  31. Modifying Web Form Properties • Dynamic controls: controls whose properties change while the form is running • Because Web programmers reference dynamic controls in program commands, it is important to assign descriptive ID attribute values to them • Both Label and TextBox rich server controls have a Text property that specifies the text that the control displays when the form first opens Database-Driven Web Sites, Second Edition

  32. Writing Server-Side Web Form Programs • Every Web form has an associated code behind file that contains the code that works with the Web form controls • The code behind file is edited in the Browser Window’s Code editor Database-Driven Web Sites, Second Edition

  33. Writing Server-Side Web Form Programs Database-Driven Web Sites, Second Edition

  34. Writing Server-Side Web Form Programs • Code editor: an environment to enter, display, and edit program commands or text files  • Code behind file: contains VB .NET commands that define and process Web form components • Declarations block: • First set of commands in the code behind file • Contains the commands that define the Web form and its components Database-Driven Web Sites, Second Edition

  35. Writing Server-Side Web Form Programs • Code behind file also contains procedures, which are self-contained code blocks written in one of the .NET programming languages • Procedures can be functions and event handlers • VB .NET procedures can also be subroutines, which are similar to functions and can receive and manipulate parameter values, but do not return a specific value Database-Driven Web Sites, Second Edition

  36. Building and Testing the Project • Building the project: translates the project files into machine-readable code that the Web server can execute • Every time a change is made to a project, the project assembly file must be rebuilt • Build Solution or Rebuild Solution: to rebuild the project • Another way to build or rebuild the project files is to run the project in the Visual Studio .NET IDE Database-Driven Web Sites, Second Edition

  37. Building and Testing the Project • Visual Studio .NET Debugger: to set breakpoints, step through commands, and view variable values during execution • Project Start Page: must be specified before running a project in Visual Studio .NET Database-Driven Web Sites, Second Edition

  38. Accessing and Referencing Web Forms • Users can access a Web form by entering the form’s URL in the Address field in their Web browser • Users can access Web forms through hyperlinks in static Web pages Database-Driven Web Sites, Second Edition

  39. Moving Web Application Projects to Different Locations • When a project is moved to a new location, some modifications must be made both to the project and to the Web server structure • To move a project to a new location successfully, a new Web server application must be created and it must be associated with the new project folder • Then the project solution file needs to be modified to specify the URL to the new Web server application Database-Driven Web Sites, Second Edition

  40. Summary • .NET framework: set of code, objects, and standards for building computer applications • ASP.NET can be used to create a Web application project that contains all of the application’s related files • Visual Studio .NET IDE: provides a visual interface to access, configure, manage, and debug the different application components in a single integrated environment Database-Driven Web Sites, Second Edition

  41. Summary • Server controls: elements that an HTML designer creates in a Web form • Server controls enable Web developers to create modular Web applications • The .NET framework is built on the object-oriented model and contains an extensive class library • Visual Studio .NET stores every Web form in a file with an .aspx extension Database-Driven Web Sites, Second Edition

More Related