Web Technologies-Ii
Total Page:16
File Type:pdf, Size:1020Kb
$ Edited by: Sarabjit Kumar WEB TECHNOLOGIES-II Edited By Sarabjit Kumar Printed by EXCEL BOOKS PRIVATE LIMITED A-45, Naraina, Phase-I, New Delhi-110028 for Lovely Professional University Phagwara SYLLABUS Web Technologies-II S. No. Topics 1. Making Sense of .NET & Anatomy of an ASP.NET Page: The Microsoft .NET Vision, ASP in NET, Introduction to C#, A Simple Web Page, Adding a Web Control, Introduction to In-Line Script, The Page Class. 2. Server Controls: Postback, Data Binding, Web Server Controls. 3. Server Controls: HTML Server Controls, Validation Controls. 4. Database Access: Error Handling, Database Access Using ADO.NET, Connection, Command, DataAdapter, and DataSet, DataReader, Connection Pooling. 5. Creating More Advanced ASP.NET Pages: Communicating with the Browser, Web.Config. 6. Creating More Advanced ASP.NET Pages: Page Sub-classing, User Controls, More Advanced Data Binding. 7. Applying What We’ve Learned So Far: The Database Model, Creating a Basic Object Model, Creating the User Interface. 8. Web Services: XML Web Services, Uses for Web Services, Web Services in Visual Studio .NET, Creating Web Services, Expanding Web Application with Web Services. 9. Security and Membership: IIS Security, ASP.NET Authentication. Adding E-Commerce Essentials: XML Tools, Freight Calculations, Email. 10. Debugging and Optimization: Debugging in an ASP.NET Application, Optimization, Optimizing Using Caching, Optimizing via Performance Profiling. CONTENT Unit 1: Making Sense of .NET and Anatomy of an ASP.Net Page 1 Kumar Vishal, Lovely Professional University Unit 2: Introduction to C# 25 Sarabjit Kumar, Lovely Professional University Unit 3: Server Controls Basic 42 Sarabjit Kumar, Lovely Professional University Unit 4: Advanced Server Controls 58 Sarabjit Kumar, Lovely Professional University Unit 5: Database Access 83 Sarabjit Kumar, Lovely Professional University Unit 6: Error Handling 107 Sarabjit Kumar, Lovely Professional University Unit 7: Advanced ASP.NET 129 Kumar Vishal, Lovely Professional University Unit 8: Creating More Advanced ASP.NET 145 Kumar Vishal, Lovely Professional University Unit 9: The Database Model 173 Sarabjit Kumar, Lovely Professional University Unit 10: Web Services 197 Sarabjit Kumar, Lovely Professional University Unit 11: Web Services in Visual Studio .NET 221 Kumar Vishal, Lovely Professional University Unit 12: Security and Membership 235 Sarabjit Kumar, Lovely Professional University Unit 13: Adding E-Commerce Essentials 251 Sarabjit Kumar, Lovely Professional University Unit 14: Debugging and Optimization 265 Sarabjit Kumar, Lovely Professional University Corporate and Business Law 6 LOVELY PROFESSIONAL UNIVERSITY Kumar Vishal, Lovely Professional University Unit 1: Making Sense of .NET and Anatomy of an ASP.NET Page Unit 1: Making Sense of .NET and Anatomy of an Notes ASP.NET Page CONTENTS Objectives Introduction 1.1 Features of .NET 1.2 The Challenges of Building Modern Applications 1.2.1 Limitations in Win32 Clients 1.2.2 Limitations in DNA Based Internet Development or Browser Based Clients 1.3 .NET Philosophy 1.3.1 Microsoft.NET solutions 1.3.2 Other Benefits of using .NET architecture 1.3.3 N-tier Architecture with .NET 1.4 Understanding the .NET Platform and its Layers 1.4.1 Constituents of .NET Platform 1.4.2 The Common Language Runtime (CLR) 1.4.3 The .NET Class Framework 1.4.4 User Interface 1.4.5 Languages 1.4.6 .NET Products 1.4.7 .NET Services 1.4.8 .NET Runtime 1.5 Understanding the Various Components of the .NET Platform 1.5.1 Common Language Runtime 1.5.2 Automatic Memory Management 1.5.3 Common Type System 1.5.4 Common Type System Architecture 1.6 ASP in .NET 1.6.1 Many Faces of ASP.NET 1.7 Problems with Traditional ASP 1.8 Advantages of ASP.NET 1.9 ASP.NET Architecture 1.10 Summary 1.11 Keywords 1.12 Review Questions 1.13 Further Readings LOVELY PROFESSIONAL UNIVERSITY 1 Web Technologies-II Notes Objectives After studying this unit, you will be able to: • Discuss the features of .NET • Define challenges of building modern applications • Discuss the .NET philosophy • Understand the .NET platform and its layers • Define the various components of the .NET platform • Describe ASP in .NET • Discuss the problems with traditional ASP • Define the advantages of ASP.NET • Discuss the ASP.NET architecture Introduction Microsoft .Net Framework is a programming communications created by Microsoft for edifice, deploying, and operation applications and services that use .NET technologies, such as desktop applications and Web services. The Microsoft .NET Framework is a software framework that can be installed on computers running Microsoft Windows operating systems. It includes a large library of coded solutions to common programming problems and a virtual machine that manages the execution of programs written specifically for the framework. The goal in application development is always the same: Create the best possible software in the least amount of time. Yet the bar is continually raised, as demands from customers increase. To meet these demands, the platforms developers build on and the tools they use must get better and better they must evolve. Consider the illustration in Figure 1.1. Figure 1.1: .Net Framework .NET Framework 3.5 CLR Add-in Additional LINQ ASP.NET 3.5 Framework Enhancements .NET Framework 3.0 + SP1 Windows Windows Windows Windows Communication Workflow Presentation Card Space Foundation Foundation Foundation .NET Framework 2.0 + SP1 2 LOVELY PROFESSIONAL UNIVERSITY Unit 1: Making Sense of .NET and Anatomy of an ASP.NET Page 1.1 Features of .NET Notes The following features are: Rich Functionality Out Of the Box The .NET framework provides rich set of functionality out of the box. It contains hundreds of lessons that provide assortment of functionality ready to use in your applications. This means that as a developer you need not go into low level details of many operations such as file IO, network communication and so on. Easy Development of Web Applications The ASP.NET is a technology accessible on .NET stage for developing dynamic and data driven web applications. ASP.NET provides an event driven programming model (similar to Visual Basic 6 that simplify development of web pages (now called as web forms) with complex user interface. ASP.NET server controls provide advanced user interface elements (like calendar and grids) that save lot of coding from programmer’s side. OOPs Support The advantages of Object Oriented programming are well known. .NET provides a fully object oriented environment. The philosophy of .NET is “Object is mother of all.” Languages like Visual Basic.NET now support many of the OO features that were lacking traditionally. Even primitive types like integer and characters can be treated as objects something not available even in OO languages like C++. Multi-Language Support Generally enterprises have varying skill sets. For example, a company might have people with skills in Visual Basic, C++, and Java etc. It is an experience that whenever a new language or environment is invented existing skills are outdated. This naturally increases cost of training and learning curve. .NET provides something attractive in this area. It supports multiple languages. This means that if you have skills in C++, you need not throw them but just mould them to suit .NET environment. Currently four languages are available right out of the box namely Visual Basic .NET, C# (pronounced as C-sharp), Jscript.NET and Managed C++ (a dialect of Visual C++). There are many vendors that are working on developing language compilers for other languages (20+ language compilers are already available). The beauty of multi-language support lies in the fact that even though the syntax of each language is different, the basic capabilities of each language remain at par with one another. Multi-Device Support Modern life style is increasingly embracing mobile and wireless devices such as PDAs, mobiles and handheld PCs. .NET provides promising platform for programming such devices. .NET Compact Framework and Mobile Internet Toolkit are step ahead in this direction. Automatic memory management While developing applications developers had to develop an eye on system resources like memory. Memory leaks were major reason in failure of applications. .NET takes this worry away from developer by handling memory on its own. The garbage collector takes care of freeing unused objects at appropriate intervals. Compatibility with COM and COM+ Before the preface of .NET, COM was the de-facto standard for componentized software development. Companies have invested lot of money and efforts in developing COM components and controls. The good news is you can still use COM components and ActiveX controls under LOVELY PROFESSIONAL UNIVERSITY 3 Web Technologies-II Notes .NET. This allows you to use your existing investment in .NET applications. .NET still relies on COM+ for features like transaction management and object pooling. In fact it provides enhanced declarative support for configuring COM+ application right from your source code. Your COM+ knowledge still remains as a valuable asset. No more DLL Hell If you have worked with COM components, you most likely are aware of “DLL hell”. DLL conflicts are a common fact in COM world. The main reason behind this was the philosophy of COM “one version of component across machine”. Also, COM components require registration in the system registry. .NET ends this DLL hell by allowing applications to use their own copy of dependent DLLs. Also, .NET components do not require any kind of registration in system registry. Strong XML support Now days it is hard to find a programmer who is uninformed of XML. XML has gained such a strong industry support that about all the vendors have released some kind of upgrades or patches to their existing software to make it “XML compatible”. Currently, .NET is the only platform that has built with XML right into the core framework.