Svetlin Nakov Telerik Corporation www.telerik.com.

Slides:



Advertisements
Similar presentations
Unit 02. ASP.NET Introduction HTML & Server controls Postbacks Page Lifecycle.
Advertisements

Svetlin Nakov Telerik Corporation
Master Pages, User Controls, Site Maps, Localization Svetlin Nakov Telerik Corporation
11 ASP.NET Slides based off:. 22 B ACKGROUND - W EB A RCHITECTURE Web Server PC/Mac/Unix/... + Browser Client Server Request:
Building Applications using ASP.NET and C# / Session 1 / 1 of 21 Session 1.
Anatomy of an ASP.NET Page. Slide 2 My Version of the Big Picture (1) ASP Worker (Engine) Your application Runs Server Other applications User 1User 2.
Web Development in Microsoft Visual Studio Slide 2 Lecture Overview Introduce Visual Studio 2013 Create a first ASP.NET application.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 1.1 of…
Web-Based Applications
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
IT 533 Lecture Notes Gül ş en Demiröz Introduction to Web Programming using ASP.NET.
 Mark Friedman Architect Developer Division Microsoft Corporation.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 8: WebForms — Web-based.
Telerik Software Academy ASP.NET Web Forms.
ASP.Net, Web Forms and Web Controls 1 Outline Introduction Simple HTTP Transaction System Architecture Creating and Running a Simple Web Form Example Web.
Introduction to.Net and ASP.Net Course Introduction Build Your Own ASP.Net Website: Chapter 1 Microsoft ASP.Net Walkthrough: Creating a Basic Web Forms.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
© 2004 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin Programming the Web Using ASP.Net Chapter 2: The ASP.Net Template Dave.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
JavaScript & jQuery the missing manual Chapter 11
Introduction to ASP.NET. Prehistory of ASP.NET Original Internet – text based WWW – static graphical content  HTML (client-side) Need for interactive.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Object-Oriented Application Development Using VB.NET 1 Chapter 12 Web Forms, HTML, and ASP.NET.
ASP.NET INTRODUCTION INTO وزارة التربية و التعليم العالي كلية العلوم و التكنولوجيا قسم علوم الحاسوب و تكنولوجيا المعلومات اعداد الاستاذ: عبد الله محمد.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
An Introduction to ASP.NET Ed Dunhill blogs.msdn.com/edunhill SLIDE7.
Overview of Previous Lesson(s) Over View  Server controls are small building blocks of the graphical user interface, which includes  Text boxes  Buttons.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
© 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University.
Beginning Web Site Development Module 1 – Dynamic Web Site Development Fundamentals of building dynamic Web sites with ASP.NET 2.0 and C# Version.
ASP.NET Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
IT 533 Lecture Notes Introduction to Web Programming using ASP.NET.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind.
The Web Architecture and ASP.NET. Slide 2 Review of the Web (1) It began with HTTP and HTML, which delivers static Web pages to browsers which would render.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
Overview of Previous Lesson(s) Over View  SDI programs  The Application Wizard can generate single-document interface (SDI) applications that work.
Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,
Anatomy of an ASP.NET Page. Slide 2 Compiling an ASP.NET Page An ASP.NET page is compiled when it is rendered for the first time A page is compiled to.
Active Server Pages (ASP), also known as Classic ASP or ASP Classic, was Microsoft's first server-side script engine for dynamically generated web pages.
Module 4: Creating a Microsoft ASP.NET Web Form. Overview Creating Web Forms Using Server Controls.
Beginning ASP.NET (Part 3).NET 2.0 Core Libraries Tuc Goodwin.
PAGE DIRECTIVES. Page Directives  They are instructions, inserted at the top of an ASP.NET page, to control the behavior of ASP.NET pages.  So it is.
Christopher M. Pascucci.NET Programming CodeBehind.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
ASP.NET in Definition: 1.ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites,
ASP.NET 4 Unleashed Chapter 1. .aspx page: contains C# script and HTML code including tags. Listing 1.1 FirstPage.aspx.
ASP.NET (Active Server Page) SNU OOPSLA Lab. October 2005.
Understanding Web Applications Lesson 4. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Web Page Development Understand Web.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Asp.NET Core Server Controls. Slide 2 Lecture Overview Understanding the types of ASP.NET controls HTML controls ASP.NET (Web) controls.
Overview of Previous Lesson(s) Over View  ASP is a technology that enables scripts in web pages to be executed by an Internet server.  ASP.NET is a.
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
Sergey Sidorov PhD student, computer software chair Computer Science department.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
ASP.NET Architecture Mike Taulty Developer & Platform Group Microsoft Ltd
ASP.NET Overview Brian Hitney Developer Evangelist Microsoft Corporation
Computing with C# and the .NET Framework
ASP.NET Forms.
Web Application Web Application are programs that can be executed either on a Web server or in a Web browser. An Online store accessed through a browser.
Introduction to Client-Server Programming
Haritha Dasari Josue Balandrano Coronel -
Web Development in Microsoft Visual Studio 2013
Anatomy of an ASP.NET Page
ASP.NET Module Subtitle.
ASP.NET Imran Rashid CTO at ManiWeber Technologies.
Presentation transcript:

Svetlin Nakov Telerik Corporation

1. Introduction to ASP.NET  History of ASP.NET  ASP.NET Benefits 2. ASP.NET Architecture Overview  Separation of Presentation from Logic 3. ASP.NET Base Components  Web Forms  Web Controls 2

4. ASP.NET Execution Model  Application Life Cycle  Page Life Cycle 5. Internet Information Server (IIS 5.1/6.0/7.0) 6. Creating ASP.NET forms 7. Code-behind 8. Directives 3

 At the beginning of Internet (up to 1997)  CGI, ISAPI – C, C++  Classic ASP ( )  Based on VB Script, COM, ADO  ASP.NET 1.0 / 1.1 ( )  The First.NET based Web Development API  ASP.NET 2.0 ( ) – based on.NET 2.0  ASP.NET 3.5 ( ) – LINQ to SQL  ASP.NET 4.0 (2010) 5

 Separate presentation from code  Object-oriented approach  Component-based development  Event-driven architecture  Code compilation  Extensible architecture  Built-in state management  Many others (data binding, validation, master pages, etc.) 6

 ASP.NET applications are executed via a sequence of HTTP requests and HTTP responses  Client Web browser request ASPX pages  The Web server executes the ASPX page and produce XHTML + CSS + JavaScript 8

Windows Server Internet Information Server (IIS) ISAPI Filters (aspnet_isapi.dll) ASP.NET runtime (aspnet_wp.dll / w3wp.dll) XML-basedconfiguration HttpApplication Cache HttpModules Session state Authentication … Session state Authentication … HttpHandlers ASP.NET pages ASP.NET Web services … Html Controls AJAX Web controls User controls …

 Traditional Web pages (static HTML)  Consist of static HTML, images, styles, etc.  Execute code on the client side  Simple operations  ASP.NET Web Forms  Execute code on the server side  Database access  Dynamic pages  Higher security level 10

 Traditional Web development keep HTML and programming code in one file (PHP, ASP, …)  Hard to read, understand and maintain  Hard to test and debug  ASP.NET splits the Web pages into two parts: .aspx file containing HTML for visualization  "Code behind" files (.cs for C#) containing presentation logic for particular page 11

 Class generated from the.aspx file does not derives directly from Page class  Derives from class defined in the "code behind", where it is easy to add methods, event handlers, etc.  Using "code behind" separates the presentation logic from UI visualization 12 System.Web.UI.Page TestForm.aspx.cs TestForm.aspx

 Steps to create a simple ASP.NET Web application: 1.Start Visual Studio 2.Create “New Web Site” 3.Add two text fields, a button and a label 4.Handle Button.Click and implement logic to calculate the sum of the values in the text fields 5.Display the results in the label 13

Live Demo

 Web Forms – deliver ASP.NET user interface  Web Control – the smallest part we can use in our Web application (e.g. text box)  "Code behind" – contains the server-side code  Web.config – contains ASP.NET application configuration  Machine.config – contains configuration for all applications on the ASP.NET server  Global.asax – class containing application level event handlers 16

 ASP.NET Web controls are the smallest component part  Deliver fast and easy component-oriented development process  HTML abstraction, but finally everything is HTML 17 <asp:button runat="server" ID="btn" <asp:button runat="server" ID="btn" Text="Click me!" OnClick="btn_Click" /> Text="Click me!" OnClick="btn_Click" /></form>

 Main settings and configuration file for ASP.NET  Text based XML document  Defines:  Connection strings to any DB used by app  The default language for child pages  Whether debugging is allowed 18 <configuration> </configuration> Minimal Web.config should look like this

 Text based XML document  Contains settings that apply to an entire computer 19

 Also known as ASP.NET application file  Located in the Web application root folder  Exposes application and session level events  Application_Start  Application_End  Session_Start  Session_End  … 20

Live Demo

 First call to particular page 23

 Any other call after the first 24

1. IIS receives the HTTP request 2. IIS using ISAPI sends the request to aspnet_wp.exe 3. ASP.NET receives request for the first time 4. Basic ASP.NET objects are created for every request (e.g. Request, Response, etc.) 5. Request is associated with the HttpApplication object 6. HttpApplication process the request 25

 PreInit  Init  InitComplete  PreLoad  Load  LoadComplete  PreRender  PreRenderComplete  SaveStateComplete  Unload 26

 PreInit  Create or recreate controls, set the master page or theme  Init  InitComplete  PreLoad  Load  LoadComplete  PreRender  PreRenderComplete  SaveStateComplete  Unload 27

 PreInit  Init  All controls are initialized  Use it to set some control properties  InitComplete  PreLoad  Load  LoadComplete  PreRender  PreRenderComplete  SaveStateComplete  Unload 28

 PreInit  Init  InitComplete  Use it when you need all the control initialization done  PreLoad  Load  LoadComplete  PreRender  PreRenderComplete  SaveStateComplete  Unload 29

 PreInit  Init  InitComplete  PreLoad  Some processing before Load event  After this the Page object loads the view-state  Load  LoadComplete  PreRender  PreRenderComplete  SaveStateComplete  Unload 30

 PreInit  Init  InitComplete  PreLoad  Load  Here we do common processing (e.g. bind controls)  LoadComplete  PreRender  PreRenderComplete  SaveStateComplete  Unload 31

 PreInit  Init  InitComplete  PreLoad  Load  LoadComplete  PreRender  Executed after data binding  Make some final changes over controls  PreRenderComplete  SaveStateComplete  Unload 32

 PreInit  Init  InitComplete  PreLoad  Load  LoadComplete  PreRender  PreRenderComplete  Happens right before the page content is rendered  SaveStateComplete  Unload 33

 PreInit  Init  InitComplete  PreLoad  Load  LoadComplete  PreRender  PreRenderComplete  SaveStateComplete  Any changes over the page content are ignored  Unload 34

 PreInit  Init  InitComplete  PreLoad  Load  LoadComplete  PreRender  PreRenderComplete  SaveStateComplete  Unload  Page is unloaded from memory 35

Live Demo

 IIS 5.1  Comes with Windows XP  Only 10 simultaneous connections  A single web site  IIS 6.0  Comes with Windows Server 2003 and Windows XP Professional x64 edition  IPv6 support  Faster and more secure 38

 IIS 7.0  Comes with Windows Vista and Windows Server 2008  No connection limit  Restricts performance based on active concurrent requests 39

 IIS is a traditional HTTP server  Can process static and dynamic content (through the ISAPI interface)  Handles ASP.NET requests through ISAPI extension for.NET Framework  aspnet_wp.exe ( w3wp.exe in Server 2003)  ISAPI filter (Internet Server Application Program Interface)  aspnet_isapi.dll 40

 ISAPI file extension mapping 41

 ASP.NET Web Form is a programmable Web page (.aspx file)  Acts as a user interface (UI) of an ASP.NET application  Consists of HTML, code and controls which are executed on a web server  The user sees the result in the form of HTML generated by the web server  The code and controls which describe the web form don’t leave the server 43

 The functionality of the Web form is defined by using three layers of attributes 44 Page Language="c#" Codebehind="TestWebForm.aspx.cs" Codebehind="TestWebForm.aspx.cs" Inherits="MyFirstWebApplication.WebForm"%> Inherits="MyFirstWebApplication.WebForm"%><html> My First WebForm My First WebForm </html>

 Page attributes define global functionality 45 Page Language="c#" Codebehind="TestWebForm.aspx.cs"Inherits="MyFirstWebApplication.WebForm"%><html> My First WebForm My First WebForm </form></body></html>

 body tags define the appearance of a web page  MS_POSITIONING : FlowLayout, GridLayout 46 Page Language="c#" Codebehind="TestWebForm.aspx.cs"Inherits="MyFirstWebApplication.WebForm"%><html> My First WebForm My First WebForm </form></body></html>

 form attributes define how the groups of controls are going to be processed 47 Page Language="c#" Codebehind="TestWebForm.aspx.cs"Inherits="MyFirstWebApplication.WebForm"%><html> My First WebForm My First WebForm </form></body></html>

 Defines how the controls are going to be processed  In a Web form there can be several tags  Only one server-side tag 48 HTML version … … <form>…</form><form>…</form> ASP.NET version (only 1) … … <form>…</form><form>…</form>

 id – form identifier  method - specifies the method of sending information back to the server  GET – in the URL  POST – within the body of the HTTP request  runat - tells the parser that the tag is not an HTML element but an ASP.NET server control 49

50 <html><head> WebFormTest WebFormTest <meta name="GENERATOR" Content="Microsoft Visual <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0"> Studio 7.0"> <meta name="vs_targetSchema" <meta name="vs_targetSchema"content=" 'HTML and controls go here 'HTML and controls go here

Live Demo

 Writing code in an ASP.NET Web form is done in three ways:  Mixed code method  The code is in the same file as the web content, mixed with the HTML code  This method is not recommended as the source code is hard to read and maintain  Inline code method  Code-behind method 53

 Writing code in an ASP.NET web form is done in three ways:  Mixed code method  Inline code method  The code is separated in a SCRIPT section in the same file  Code-behind method 54

 Writing code in an ASP.NET web form is done in three ways:  Mixed code method  Inline code method  Code-behind method  The code is in the code-behind page – a separate file from the HTML content  When using Visual Studio.NET this is the default method 55

56...</html> private void btn_Click(object sender, System.EventArgs e) {...}</script>

 A separate compiled file containing the program logic of the page  Each web page has its own code-behind page  Has the same name as the web page to which it is attached  The file extension is.aspx.cs  The two files are built into one when the application is started 58

 To associate an.aspx page to its code-behind class directive is used  VS.NET adds three attributes to directive:  Inherits – allows the.aspx page to derive from the code-behind class  Codebehind – used internally by Visual Studio.NET to associate the files  Src – contains the name of the code-behind page  Used if the application is not precompiled 59

60 Page Language="c#" Inherits="MyProject.WebFormTest"Codebehind="WebFormTest.aspx.cs" Src="WebFormTest.aspx.cs" %>

 The Code-behind page can be either precompiled or just-in-time (JIT) Compiled  JIT compilation  A compilation at first request  Set by the Src attribute of directive  VS.NET doesn’t add it by default 61

 Precompilation  Avoids the delay at first request  Simplifies the deployment of the web application  The source code of the code-behind class is not necessary 62

 Provide control over many options affecting the compilation and execution of the web form  Important directives: – main directive of the page – imports a namespace into the – attaches an assembly to the form when it is compiled – controls the ability of the forms to use cache – registers a user control to be used in a web form 64

 Defines a form specific (.aspx file) attributes used by the parser and the compiler of ASP.NET  Important attributes:  AutoEventWireup  Culture – a culture used when the page is generated  UICulture – a culture used for the visualization of data 65

 Important attributes:  Debug – whether the page is compiled with debug symbols in it  EnableSessionState – whether a session is supported  EnableViewState – whether to use "view state“ or not  ErrorPage – a page to which to redirect in case of unhandled exception 66

 Important attributes:  Language – states the program language used to script the page  Codebehind – points to the code-behind file where the page logics is stored  Smart-Navigation – improves user experience over post backs  Persists element focus and scroll position  Avoids flickers  Supported by IE 5.5 or later  Shouldn’t use it - problematic 67

Live Demo

Questions?

1. Start Visual Studio 2010 and make new Web Site. Look at the files generated and tell what's purpose of each file. Explain "code – behind" model. Print "Hell ASP.NET" from code – behind and from UI. Show automatic generated files in executing directory using Assembly.GetExecutingPath(). 2. Create a Web page which saves empty file in ProgramFiles directory. Configure directory security so IIS process to be able to write in there. 3. Catch all the events in page lifecycle using appropriate method or event handler. 70

4. Do some kind of tracing of these events. 5. Create an HTML form that posts the contents of a textarea field to a server and the server prints it in another field. Don’t use code-behind. 6. Create an ASP.NET web form which posts the contents of a textarea field to a server and the server prints it in another field. 7. Use the src attribute of directive to create a page that doesn’t need to be precompiled. 71