Dynamic Web Programming BUILDING WEB APPLICATIONS USING ASP.NET, AJAX AND JAVASCRIPT
AGENDA 1. Introduction to Web Applications and ASP.net 1.1 History of Web Development 1.2 Basic ASP.net processing (ASP classic) 1.3 Introduction to ASP.net 1.4 Main Features of ASP.NET 1.5 Introduction to Visual Web Developer
Building Web Applications Using ASP.NET, AJAX And JavaScript 1. INTRODUCTION TO WEB APPLICATIONS AND ASP.NET
1.1 HISTORY OF WEB DEVELOPMENT 1 15 years ago first transmission across HTTP. HTML and XML were quickly developed to build application that discover and interact with each other. HTML = display rich documents on any platform. XML = define platform-neutral data formats. Next challenge was to create tools for developers to design, build, and deploy web applications. ASP.NET is the latest web development platform from Microsoft. Two early web development technologies: Separate, tiny applications that are executed by server-side calls(cgi interface) Scripts that are interpreted by a server-side resource (ASP classic, Cold Fusion). Embed scripts into HTML pages. ASP.NET blurs the line between application development and web development by extending the tools and technologies of desktop developers into the web development world.
1.2 BASIC ASP.NET PROCESSING (ASP CLASSIC) 2 ASP classic was the first powerful web development tool. Biggest issue was spaghetti code: ASP Classic is processed from top to bottom, and server-side code was intermingled with HTML. HTML faced the same issues early on, therefore separation of content and presentation (using CSS). Very difficult to manage large web development projects. Example 1-1 shows the basic structure of an ASP classic page. Second biggest issue: VB Script (scripting language). VB comes from the client-server world and is not geared towards web technologies. Mainly performance issues with VB Script. For example, variables are declared as Variants (no specific data type), This requires more overhead to keep track of the kind of data and to perform conversions when operating on these variables.
1.2 BASIC ASP.NET PROCESSING (ASP CLASSIC) 3
1.3 INTRODUCTION TO ASP.NET 4 ASP.NET works fundamentally different, code is compiled and not interpreted! ASP.NET features a completely object-oriented programming model. Code in any.net supported language, third-party compilers are already available for other languages. ASP.NET was designed for performance, pages are compiled on demand only and not interpreted after every request. Then the page is cached for even better performance. Many more features, such as enhanced state management, practical data binding, dynamic graphics, and a robust security model. ASP.NET is integrated with.net Framework The.NET platform contains over 10,000 types (classes, structures, interfaces, other core elements).
1.3 INTRODUCTION TO ASP.NET 5 This massive collection of functionality is well organized. Each type is grouped into a logical, hierarchical container called a namespace. Different namespaces provide different features, this is like having a huge toolkit to build powerful applications. This toolkit is called the class library. Interestingly, the way you use the.net Framework classes in ASP.NET is the same as the way you use them in any other type of.net application, such as Windows Forms application, for example. ASP.NET is compiled, not interpreted Every time an ASP classic page is executed, a scripting host on the web server needs to interpret the script code and translate it to lowerlevel machine code, line by line. This is just slow..net apps are compiled in two stages, first to Intermediate Language (IL), then when page is requested into machine code (Just in time).
1.3 INTRODUCTION TO ASP.NET 6 JIT would not be useful if compilation takes place every time a page is requested. Once the page is requested and compiled it does not to be compiled again, it is cached. Only when the source of the page is changed, then recompilation takes place. VB.net Code VB.net Compiler C# Code C# Compiler Intermediate Language (IL) Code Just in Time (JIT) Compiler Other.net Code Other.net Compiler Common Language Runtime (CLR) Machine Code Execute
1.3 INTRODUCTION TO ASP.NET 7 ASP.NET is Multilanguage All languages in.net are compiled into IL (Intermediate Language), IL is the language of.net. You can write one page in C# and the other one in VB.NET (possibly good for teams of developers) ASP.NET hosted by Common Language Runtime (CLR) ASP.NET runs within CLR, entire.net framework (namespaces, applications, classes) is referred to as managed code. Benefits of managed code: Automatic memory management and garbage collection Type safety (.NET adds classes, their members, and data types to assembly, other apps can use them without any additional support files). Extensible metadata (metadata is stored in assembly) Structured error handling Multithreading, no need to create explicitly new threads
1.3 INTRODUCTION TO ASP.NET 8 ASP.NET is Object-Oriented (OO) ASP.NET provides small set of objects, just a thin layer over HTTP and HTML. On the other hand, ASP.NET is truly object-oriented. ASP.NET has full access to all objects in entire.net framework. Example: Server-based controls, they represent the epitome of encapsulation. Developers can manipulate controls programmatically, react to events, etc. ASP.NET will generate pure HTML to display those controls after processing. ADO.net Web Forms Windows Forms XML File I/O More... Core Classes (Threading, Serialization, Collection, etc.).net Class Library Compiler and Loader Code Verification and Optimization Memory Management and Garbage Collection Code Access Security Other Managed Code Services The Common Language Runtime
1.3 INTRODUCTION TO ASP.NET 9 ASP.NET is Multidevice and Multibrowser Web developers always faced the challenge to support wide variety of browsers. ASP.NET avoids this issue by providing server controls, the developer creates these controls in ASP, the ASP engine will then render them adaptively into HTML by taking the client s environment into consideration. Validation controls are great example, they generate JavaScript browser agnostically. ASP.NET is easy to Deploy and Configure No more component registering and configuration settings. ASP.NET contains all the information in the assembly. Simply copy the entire assembly to the web server (components, such as dll, and metadata). Configurations settings are stored in web.config file
1.4 MAIN FEATURES OF ASP.NET 10 Rich Controls ASP.NET contains more than 40 controls, prebuilt components that offer huge functionalities. TreeView, JavaScript powered Menu, GridView data controls, Calendar controls Master Pages Reusable page templates to brand your web site in a consistent fashion. Create consistent header, footer, navigation controls for all pages in your web app Themes Define standardized set of appearance characteristics for web controls. Creates consistent look and feel for your web site. Security and Membership Automatic support for storing user-credentials, role-based authorization, and prebuilt security controls such as login, logout, password recovery, etc. Data Source Controls Declarative controls to manage interaction with data sources, such as databases, XML, etc.
1.4 MAIN FEATURES OF ASP.NET 11 Web Parts Web parts provide prebuilt portal framework complete with flow-based layout, configurable views, and even drag-and-drop support. Profiles LINQ Allows you to store user-specific information in a database without writing any database code. ASP.NET retrieves profiles when needed and saves changes back to the database. Language Integrated Query is a set of extensions for C# and VB to write code that manipulates in-memory data in much the same way you query a database. ASP.NET AJAX Asynchronous JavaScript and XML, client-side tools allowing for partial updates in your web page rather than a complete postback. Silverlight New Microsoft technology allows a variety of browsers on a variety of operating systems to run true.net code (through browser plug-in)
1.5 INTRODUCTION TO VISUAL DEVELOPER 12 Visual Web Developer is part of Visual Studio allowing you to built ASP.NET web pages. Start page contains News page displaying most current information about ASP.NET and other technologies. Also a section showing most recent projects and a Getting Started section. Open/Create Web Site: File-based assembly where all files must be deployed on the web server. (Good for development) Open/Create Web Project: All code pages are compiled into a single assembly. (Good for QA, Production)
1.5 INTRODUCTION TO VISUAL DEVELOPER 13
1.5 INTRODUCTION TO VISUAL DEVELOPER 14
1.5 INTRODUCTION TO VISUAL DEVELOPER 15 Important Features of Visual Web Developer: Integrated Web Server: To run ASP.NET server, you need IIS (Internet Information Services), comes with Windows, however, fairly complex to set up. Use built-in web server in Visual Developer (Cassini). Multilanguage Support: In one page, you must use one language, however, you can mix language in a web site.
1.5 INTRODUCTION TO VISUAL DEVELOPER Less Code to Write: ASP.NET pages require fair bit of standard boilerplate code, Visual Web Developer automatically generates a massive amount of standard code. Intuitive Coding Style: Visual Web Developer formats your code as you type. Using color coding and IntelliSense makes coding even easier. Use Tools Options to customize automatic formatting. Faster development Time: Most features in Visual Web Developer are geared toward helping you get your work done faster: IntelliSense, search-and-replace, automatic comment/uncomment, Code Refactor, and Find All References Files Description Debugging: Best debugging tools on the market. Using IE, you can even debug JavaScript. Solution Explorer: Manage all files in web project..aspx.ascx.asmx or.svc Web.config global.asax.cs 16 ASP.NET web pages containing the user interface such as forms, controls, navigation, etc. ASP.NET user controls, grouped controls including code functionality packaged as a unit. These controls must be embedded in an aspx file. ASP.NET web services or Windows Communication Services (.svc). XML based configuration file for customizing security, state management, memory management, etc. Global application file for defining global variables and reacting to global events. C# code files, either directly associated with aspx web pages or stand-alone class files.
1.5 INTRODUCTION TO VISUAL DEVELOPER 17 Document window Toolbox View in Browser Debug Solution Explorer Database Explorer Document window ASP Page View (Design, Split, Source) CSS Properties Manage Styles Error List Task List Output Window Properties
1.5 INTRODUCTION TO VISUAL DEVELOPER 18 Toolbox Output Window Error List Task List Properties Window Database Explorer Manage Styles, CSS Properties