370 likes | 514 Views
ASP.NET 2.0. Chapter 11 Advanced Web Programming. Objectives. Building Reusable Code. To replicate the same behaviors and programming across applications, the code would need to be created in each application
E N D
ASP.NET 2.0 Chapter 11 Advanced Web Programming
Objectives ASP.NET 2.0, Third Edition
Building Reusable Code • To replicate the same behaviors and programming across applications, the code would need to be created in each application • ASP.NET technologies gives the developer the ability to create and reuse classes and assemblies ASP.NET 2.0, Third Edition
Creating Reusable Code with Classes • The process of creating a shared class works like this: • 1. When the class is created in the editor, identify the program language that will be used to create the class • The program will save classes written in C# with the .cs file extension and in Visual Basic with the .vb file extension • 2. After creating and saving the class file, run the web application by viewing one of the web pages in a browser • 3. The first time the web application is run, the program recognizes the file extension for classes defined in the App_Code folder and compiles the classes and adds them to the web application assembly • 4. Classes that could be written in multiple languages, such as XML schemas (.xsd), will be compiled with the default compiler configured in the compilation element of the web application or machine configuration file ASP.NET 2.0, Third Edition
Calling the Class from the Web Page • After you have created the class, your web page can access the data by simply instantiating the class as a new object from the base class with the keyword New, and then calling the function using the new class • If a stored procedure changes, you need only change the stored procedure within one page, instead of throughout all the pages on your site • A component is a class file that contains your reusable programming code • The process of adding an object to the component is the same as adding an object to an ASP.NET page ASP.NET 2.0, Third Edition
Calling the Class from the Web Page (continued) • It is useful to be able to extend classes and one way to do this is through creating a derived class • The new derived class could have additional properties, events, and methods associated with the class that were not defined in the original class • Create the control dynamically within the web page using a constructor • The constructor is simply the code to create the object based on the original class • After creating the controls based on the class definition files, or using the constructors, you have to add them to the controls collection on the page, or to a PlaceHolder control ASP.NET 2.0, Third Edition
Creating and Using Classes ASP.NET 2.0, Third Edition
Creating and Using Classes (continued) ASP.NET 2.0, Third Edition
Creating and Using Classes (continued) ASP.NET 2.0, Third Edition
Creating and Using Classes (continued) ASP.NET 2.0, Third Edition
Using Code Snippets • Create snippets of code and store them within the Toolbox • Create your own tabs to customize the Toolbox • Code Snippets Manager is a new tool that allows you to select from some of the commonly used activities from a predefined list • Use the Code Snippets Manager to insert sample code; then, you will customize the code for your application ASP.NET 2.0, Third Edition
Using Code Snippets (continued) ASP.NET 2.0, Third Edition
Using Code Snippets (continued) ASP.NET 2.0, Third Edition
Using Code Snippets (continued) ASP.NET 2.0, Third Edition
Using Code Snippets (continued) ASP.NET 2.0, Third Edition
Using Code Snippets (continued) ASP.NET 2.0, Third Edition
Compiling the Application • Class files in the App_Code folder are compiled dynamically at runtime when the application is first called; the source code is available using a text editor • Compile your class files into assemblies (.dll files) • Assemblies are stored within the Bin folder of the web site • Any classes in the Bin folder are automatically referenced in your web site • The Bin folder has the permissions to execute the code within the assemblies • Precompile the programming code to prevent any lag in response time ASP.NET 2.0, Third Edition
Compiling the Application (continued) ASP.NET 2.0, Third Edition
Third-Party Components • The Provider Model allows you to create new versions of software that easily can be created and plugged into your application; this architectural model results in applications that are more flexible, expandable, customizable, and easier to maintain • Over 1500 third-party components are downloadable for free or for purchase at the Control Gallery on the ASP.NET web site • The FreeTextBox control is a free HTML editor ASP.NET 2.0, Third Edition
Third-Party Components (continued) ASP.NET 2.0, Third Edition
Third-Party Components (continued) ASP.NET 2.0, Third Edition
Building a Complete Application • There are many sample applications, which are called starter kits • The Microsoft ASP.NET team has created these starter kits • A basic Personal Web Site, Club Web Site, Time Tracker Web Site, and Classifieds Site ASP.NET 2.0, Third Edition
Starter Kits ASP.NET 2.0, Third Edition
Planning Your Web Application • At some phases, the team members may have varying degrees of responsibilities including these members: • Customer • Business systems analyst • Software architects • Marketing research specialist • Graphic designer • Web developers • Windows developers • Database administrator • Quality control specialist • Documentation specialist • Network administrator • Trainer ASP.NET 2.0, Third Edition
Analyzing Project Requirements ASP.NET 2.0, Third Edition
Designing the User Interface and Programming Requirements ASP.NET 2.0, Third Edition
Designing the User Interface and Programming Requirements (continued) ASP.NET 2.0, Third Edition
Developing the Web Application • Once the plan is identified, the web development process begins • The plan should provide instruction to the web developers on the project requirements related to directory structure, file names, and coding and scripting requirements • There are many project management software applications available, such as Microsoft Project, that allow tracking of the key events in the development process ASP.NET 2.0, Third Edition
Testing the Web Application • A quality control specialist creates the test plan before the tests begin, which are often determined at the beginning of the project and correlate directly with the outcomes defined in the project requirements documentation • Testing of business outcomes is often called requirements testing • Quality testing of the code may be performed at various levels, from page level testing and modular testing to an integrated testing process where the servers simulate a realistic situation, such as a large increase in numbers of visitors ASP.NET 2.0, Third Edition
Maintaining the Web Application • An ongoing maintenance plan is put in place not only to detect problems, but also to prevent problems • Ongoing redevelopment will occur as needed • For example, your web site may need to upsize from Microsoft Access to SQL Server based on the number of users visiting the web site ASP.NET 2.0, Third Edition
New Tools and Technologies • Many new technologies are being developed every day that expand on the .NET platform and ASP.NET technologies • Some of the longest running issues in web development are client-side performance and compatibility, server-side performance, and resource utilization • Performance on the client is impacted by the client’s connection, network and Internet access, Internet traffic, and server capabilities ASP.NET 2.0, Third Edition
AJAX • AJAX was developed to manage client-server interactions more efficiently • AJAX uses a combination of client-side XMLHTTPRequest object, HTML, client scripting (JavaScript and Jscript), and CSS • The XMLHTTPRequest object is used to manage the exchange of data asynchronously with the web server • The need to use JavaScript is one reason for web developers not to choose AJAX • Third-party tools allow you to place ASP.NET controls inside of the AJAX container that automatically enables AJAX for the controls ASP.NET 2.0, Third Edition
Atlas • Atlas was developed to integrate AJAX with ASP.NET applications • There are three versions of Atlas • Microsoft AJAX Library is the client-side JavaScript library that works with any browser, and supports any backend web server including PHP and ColdFusion • ASP.NET 2.0 AJAX Extensions is the server-side functionality that integrates with ASP.NET. • In early release versions of Atlas, the tag prefix for the Atlas was <atlas:>; Atlas will be built into the next version of ASP.NET as <asp:> • ASP.NET AJAX Control Toolkit (formerly known as the Atlas Control Toolkit) provides free, shared source controls and components to help developers use ASP.NET AJAX Extensions more effectively ASP.NET 2.0, Third Edition
Integrating ASP.NET into Current Business Applications • Developers need to be aware of technologies available and how they could impact the systems and web applications they oversee • To help, there are many forums and user groups dedicated to ASP.NET for web developers • Once a web developer has conquered the technical issues surrounding ASP.NET, he or she should then address the business case and application for ASP.NET ASP.NET 2.0, Third Edition
Deploying an ASP.NET Web Application • The deployment of web applications does not require registration of the component or stopping the web service • Multiple versions can be installed of the same component and can restrict the use of the component to one or more Web applications • The local application cache is the default location for the assemblies for the local application • The AppDomain class manages the application process, and controls the assemblies and threads, such as loading and unloading assemblies • The global assembly cache is the default location for assemblies that are available to the entire server ASP.NET 2.0, Third Edition
Summary • Create class files and source code files and place them in the App_Code folder without directly compiling them. ASP.NET compiles the entire contents of the App_Code folder into a single assembly. Within your class definition, you can use members of an already existing class. • Create custom controls by creating a namespace and create a class definition that inherits the control class from System.Web.UI.Control. • Code Snippets Manager is a new tool that allows you to select from some of the commonly used activities from a predefined list. • Assemblies are stored within the Bin folder of the web site. The Bin folder has the permissions to execute the code within the assemblies. • The Provider Model allows you to create new versions of software that easily can be created and plugged into your application, which results in applications that are more flexible, expandable, customizable, and easier to maintain. ASP.NET 2.0, Third Edition
Summary (continued) • Many third-party components work with Asp.NET. FreeTextBox is a free HTML editor. • DotNetDuke is an open source application that developers use as a learning tool and template for beginning web sites. • The web development life cycle includes the tasks analyze, design, develop, test, deploy, and maintain. • AJAX is an acronym for Asynchronous JavaScript XML. AJAX is an architecture that allows the application to save a complete round trip to the server on post back. AJAX uses a combination of client-side XMLHTTPRequest object, HTML, client scripting (Java-Script and Jscript), and CSS. ASP.NET 2.0, Third Edition