Anatomy of an ASP.NET Page

Slides:



Advertisements
Similar presentations
Malek Kemmou Technology Architect, Application Platform Microsoft Middle East and Africa Overview of ASP.NET 2.0.
Advertisements

Unit 02. ASP.NET Introduction HTML & Server controls Postbacks Page Lifecycle.
Building Applications using ASP.NET and C# / Session 1 / 1 of 21 Session 1.
Working with ASP Pages. Slide 2 The Tag (1) Remember that most ASP.NET pages contain a single tag with the runat attribute set It’s possible to have multiple.
Asp.NET Core Server Controls. Slide 2 Lecture Overview Understanding the types of ASP.NET controls HTML controls ASP.NET (Web) controls.
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.
1 Chapter 12 Working With Access 2000 on the Internet.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 1.1 of…
 Mark Friedman Architect Developer Division Microsoft Corporation.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Web Forms. Agenda Web forms Web controls Code separation Dynamic compilation System.Web.UI.Page User controls.
JavaScript & jQuery the missing manual Chapter 11
CIS 375—Web App Dev II ASP.NET 2 Introducing Web Forms.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
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.
.Net is a collection of libraries, templates and services designed to make programming applications of all kinds, easier, more flexible (multi platform),
February 16, Aaron Cuffman Andy Nagle Adam Schultz Web Site.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Creating Web Applications Using ASP.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
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.
ASP.NET Controls. Slide 2 Lecture Overview Identify the types of controls supported by ASP.NET and the differences between them.
Introduction to ASP.NET 1www.tech.findforinfo.com.
Introduction to ASP.NET MVC Information for this presentation was taken from Pluralsight Building Applications with ASP.NET MVC 4.
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.
Introduction to ASP.NET T.Ahlam Algharasi. The Visual Studio IDE Start page 2.
Caching Chapter 12. Caching For high-performance apps Caching: storing frequently-used items in memory –Accessed more quickly Cached Web Form bypasses:
1 CS 3870/CS 5870 Note04 Session Variables and Post Back.
Overview of Previous Lesson(s) Over View  SDI programs  The Application Wizard can generate single-document interface (SDI) applications that work.
Server Control Tips & Tricks Presented by: Patrick Hynds Microsoft Regional Director CriticalSites CTO MCSD, MCSE+I, MCDBA, MCSA, MCP+Site Builder, MCT.
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.
Beginning ASP.NET (Part 3).NET 2.0 Core Libraries Tuc Goodwin.
BIT 285: ( Web) Application Programming Lecture 06: Thursday, January 22, 2015 Page Object, The Lifetime of a Web Application, Application State and Session.
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.
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 4 Unleashed Chapter 1. .aspx page: contains C# script and HTML code including tags. Listing 1.1 FirstPage.aspx.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
WEB322 ASP.NET Internals: Under the Covers – Exploring Internals, Page Lifecycle and the Compilation Model Simon Calvert Program Manager Web Platform and.
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.
Svetlin Nakov Telerik Corporation
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
PostBack  When an initial request for a page (a Web Form) is received by ASP.NET, it locates and loads the requested Web Form (and if necessary compiles.
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.
Alexey Polovinkin Post graduate student, CMC department.
Sergey Sidorov PhD student, computer software chair Computer Science department.
ASP.NET Architecture Mike Taulty Developer & Platform Group Microsoft Ltd
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Chapter 2 Creating Website with Web Forms. Objectives Understand the different project types and templates when building ASP.NET web sites. The different.
Creating Consistent Looking Websites
Creating an Interactive Web Page Lesson 2. Objectives.
Chapter 1 Getting Started with ASP.NET Objectives Why ASP? To get familiar with our IDE (Integrated Development Environment ), Visual Studio. Understand.
Windows Communication Foundation and Web Services
Class03 Introduction to Web Development (Hierarchy and the IDE)
ASP.NET Forms.
WWW and HTTP King Fahd University of Petroleum & Minerals
Session Variables and Post Back
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.
ASP MVP Web applications and Razor
Chapter 8 User Controls.
Data Virtualization Tutorial… CORS and CIS
.Net Table of contents Introduction to VS 2005
Chapter 23 – ASP.NET Outline 23.1 Introduction NET Overview
Web Development in Microsoft Visual Studio 2013
ASP.NET
ASP.NET Module Subtitle.
ASP.NET Imran Rashid CTO at ManiWeber Technologies.
Presentation transcript:

Anatomy of an ASP.NET Page

My Version of the Big Picture (1) Server Your application ASP Worker (Engine) Runs Other applications Request Response Session 1 Session 2 Client (Browser) User 1 User 2

My Version of the Big Picture (2) Server User Controls Your ASP.NET application ASP Pages Master Page(s) contains Content Page(s) HTML Docs Web.config Site.master

(Review) What is an ASP.NET Page? Roughly speaking, an ASP.NET page contains Markup (appears in the .aspx page) Server-side code that the ASP.NET worker executes (appears in the .aspx page or in a separate code behind page) The resulting HTML is sent out to the client (browser) by the asp worker process

ASP.NET Manual Event Wiring We will use AutoEventWireUp so this step will be unnecessary

Compiling an ASP.NET Page An ASP.NET page is compiled when it is rendered for the first time A page is compiled to a class that derives from System.Web.UI.Page Parse the .aspx file and create a class that derives from Page The preceding class is then compiled to an assembly This process is transparent and is handled by ASP.NET itself

Compiling an ASP page (Illustration)

IIS File Mappings .asax – application files .ascx – ASP user controls .asmx – Web services .aspx – ASP.NET Web pages

Processing Directives (1) Processing directives are used to configure the runtime environment and help the compiler Directives can appear anywhere on a page but best practices dictate that they appear at the beginning of the page Directives begin with <%@ and end with %> Make sure you don’t forget the %>

Processing Directives (Example) Processing directives have the following format: <%@ directive_name attribute=“value” attribute=“value” %> Processing directives and asp expressions work similarly https://msdn.microsoft.com/en-us/library/ydy4x04a(v=vs.85).aspx

Processing Directives (3) Processing directives are used to Describe the page itself (@ Page) Describe a special type of a page called a master page (@ Master) Control caching (@ OutputCache) And more We’ll refer back to these as the course progresses

Processing Directives (@ Page) It can appear only in .aspx pages Attributes are divided into roughly three categories Compilation Page behavior Page output There are other tools to configure the same options beyond processing directives

Processing Directives Page Compilation CodeFile lists the file containing the VB or C# code for the .aspx page Language describes the programming language for the CodeFile ClassName explicitly sets the name of the class created upon compilation This name corresponds to the name of the class declared in the underlying .cs file.

Processing Directives (Page Output) Most of these directives relate to localization and multiple cultures ClientTarget allows pages to be rendered for a specific browser

Introduction to the Page Class The Page class provides the basic behavior for an ASP Web page It’s objects allow you to reference The application itself (Application) The server itself (Server) The HTTP request (HttpRequest) The HTTP response (HttpResponse) The user’s session (Session)

Introduction to Page Events First, this topic is very important to getting your ASP applications to work ASP uses the eventing model to Persist state from one postback to the next Create static and dynamic controls Bind control instances to data sources And much more As your book says “state is an illusion of continuity”

Page Life Cycle (1) When a page is requested or posted back, the runtime figures out why the page is being processed Normal request (First time visiting a page) Postback (Page posts back to the same page) Cross-page postback (Page posts back to another page) Callback (We postback part of a page and return dat)

Page Lifecycle (Illustration)

Dissection Page methods can be overridden Page events are events that you can handle as the page is loaded and processed Control methods and events work similar to page methods and events. We handle these as controls are initialized http://forums.asp.net/t/2068013.aspx?ASP+Net+Page+Life+Cycle

Page Life Cycle (PreInit Event) It’s the first event in the page life cycle Master page has not been associated Themes have not been associated It’s possible to change master page or theme association at this time IsCallback, IsCrossPagePostback and IsPostBack are set at this time Control instances have been created so you CAN reference them in code

Page Life Cycle (Init Event) Master page and theme have been set and cannot be changed Child controls are initialized and the ID is set Child controls are initialized recursively Init event fires for all child controls before the event fires for the page itself Note that view state has not been restored yet

Page Life Cycle (InitComplete Event) Here, view state tracking is turn on The event fires only for the page

Page Life Cycle (PreLoad Event) System initialization is complete We don’t typically do much here The event only fires for pages and not controls

Page Life Cycle (Load Event) The event is raised first for the page and then recursively for all child controls You can access control properties and view state at this time Create dynamic controls in this event We won’t work with dynamic controls here Use IsPostBack to check whether the page is being loaded in response to a postback or new page

Page Life Cycle (LoadComplete Event) LoadComplete fires after Load At this point, the page begins its rendering phase We don’t generally do much here

Page Life Cycle (PreRender Event) Fires for the page first and then recursively for all controls Use to update controls before the output is rendered

Page Life Cycle (PreRenderComplete Event) Raised only for the page after PreRender has fired for all child control instances

Page Life Cycle (SaveStateComplete Event) It fires for all constituent controls and then the page itself Any changes made to control properties will not be persisted after this Next, the markup is generated

Page Life Cycle (Unload Event) After rendering, the event fires for all control instances and then the page itself Use this event to close files or database connections

Page Class Properties (1) Controls returns a collection of controls on the page IsPostBack indicates whether the page is being loaded in response to a postback or is being loaded for the first time PreviousPage returns a reference to the caller page Only meaningful in case of a cross-page postback Check IsCrossPagePostback

Page Class Properties (2) ClientTarget allows you to specify the type of browser Note that automatic browser detection is disabled EnableTheming and Theme allows you to set page themes (more later) MaintainScrollPositionOnPostback allows the page position to be persisted from one postback to the next

Page Class Methods (1) DataBind binds all data bound controls to their data sources (more later) Validate causes validation controls to validate their data SetFocus sets input focus to the desired control instance There are methods to work with client script

Folder Structure So far, you have seen a project from an empty template Now for a real one

Folder Structure You get many template files and folders for free All this gets compiled on the server to make up an ASP.NET app

Folder Structure App_Code is designed to store shared code files (classes, .wsdl pages) App_Data is designed to store data files Users can read and write data in this folder The folder Scripts is not magical but we store JavaScript and jQuery here Note that the jQuery scripts are copied here by default from the standard template

Global.asax Global.asax is the global application startup, shutdown, and error file It contains procedures that are called by the application infrastructure Application_Start called when the application gets its first request Application_End not used much Application_Error to handle all unhandled errors