Presentation is loading. Please wait.

Presentation is loading. Please wait.

Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.

Similar presentations


Presentation on theme: "Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1."— Presentation transcript:

1 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1

2 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 2

3 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 3

4 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 4

5 Terminology (1)  Dynamic web pages  Web application  Web page  Web form  Client/server application  Clients and Servers  HTTP – HyperText Transfer Protocol  Web servers and Web browsers  Round trip Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc. Slide 5

6 Terminology (2)  IIS  HTML  HTML document  HTML Request  HTMLResponse  Postback  URL  Render  aspx Code Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc. Slide 6

7 Terminology (3)  State and stateless protocol  Session  Session state object  Session ID  Application  Application state  Application state object  Assembly  Code behind  Page directives  ASP – Active Server Pages Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc. Slide 7

8 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 8

9 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 9

10 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 10

11 Dynamic Vs Static Web Pages  What’s the difference?  Handling static pages (HTML documents) like mine is comparatively simple  HTTP request  HTTP response  pages in addition to aspx – e.g., php © 2006, Mike Murach & Associates, Inc. Slide 11

12 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 12

13 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 13

14 Processing a Dynamic Web Page Request: The Round Trip  Dynamic web page – HTML document generated by a web form. The process goes like this …  Page request – web server looks up the extension in its list of application mappings  If.aspx, the file is passed on to ASP.NET for processing (things get interesting and complex)  ASP.NET is an Application Server (there are others, such as for PHP etc)  ASP.NET runs the web form, generating a pure HTML document  Server  browser  From client to server to client: round trip Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 14

15 Processing a Dynamic Page Request  This request – response sequence is called a round-trip  At the end of a round-trip the Server Application ends and its state is lost  This is important as we shall see – saving state  Once browser has the form at the client machine the user can make changes  Clicking buttons, typing text, drop down selections etc  Page then sent back to the Server (postback) Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc. Slide 15

16 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 16

17 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 17

18 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 18

19 State Concepts  State refers to the data maintained by an application for a single user.  Includes variables (reference and value) and control properties and values  An application must maintain a separate state for each user.  HTTP doesn’t keep track of state between round trips so the web application authors (YOU) must.  HTTP is a stateless protocol. Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 19

20 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 20

21 View State Concepts  View state maintains the value of form control properties (but not of any variables used in processing the form)  In other words, your basic form remains in tact  View state is implemented by default. Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 21

22 Session State Concepts  For each user, ASP.NET creates a session state object that contains a session ID.  The session ID is passed from the server to the browser and back to the server.  The session state object is kept on the server.  To maintain session state across an application (for a single user), you can add program variable and control property values to the session state object to save them across server applications (round trips) © 2006, Mike Murach & Associates, Inc.Slide 22

23 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 23 Application State Concepts

24 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 24 The New Profile Feature of ASP.NET 4.0

25 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 25

26 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 26

27 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 27

28 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 28

29 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 29

30 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 30

31 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 31

32 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 32

33 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 33

34 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 34

35 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 35

36 How an ASP.NET Application Works  Refer to the figure on the next slide   It is a web form (an Order form in this case)  It is being viewed in design form  There is a lot of “stuff” behind this form  We have to learn about this “stuff”  Note the similarities here between a web form page and your windows forms pages.  Also note the differences the smart tag arrow and drop down menu that shows up when you access that arrow Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc. Slide 36

37 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 37

38 Web Forms and Windows Forms – A Few Differences using VB 2010  Solution Explorer provides two directories:  App_Code App_Data (usually a database)  ASP.NET keeps two files for a form – both files are generated as you build your form  aspx file – holds HTML code and asp tags for server controls  aspx.vb – holds VB.NET code-behind  The smart tag arrow and drop down menu that shows up when you access that arrow Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc. Slide 38

39 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 39

40 Dissecting the Order.aspx Form (see Slide 8 & 44)   Page directive has four attributes  Specifies code behind file  Indicates the Order.aspx class inherits Order class (note use of verb inherit – the aspx code inherits the vb code)  Content of web page defined within div tags  asp tags define server controls  They and the form are processed at server  Converted to HTML and returned to browser (rendered)  Postback - page must be posted back to server  Automatically happens for button controls  Must be specified for other controls Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc. Slide 40

41 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 41

42 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 42

43 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 43

44 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 44

45 Dissecting the Order (Code-Behind)   The file name is Order.aspx.vb  Partial classes have to be combined with other partial classes in order to compile (where are the declarations for the controls???)  Load event raised each time a page is loaded  Each time a page is requested, ASP.NET initializes it (hidden) and raises the load event  Page properties: IsPostback, Response, Session, etc  DataBind – if initial page load bind ddl to a list If Not IsPostBack Then ddlProducts.DataBind() Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc. Slide 45

46 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 46

47 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 47

48 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 48

49 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 49

50 Processing an ASP.NET Application (A)  Complicated – lots of compilations  Order.aspx and Order.aspx.vb are generated normally in design mode as you drag and drop controls etc (see Chapter 2)  1. Whenever a web page is requested (through a web-server such as IIS), IIS looks at the extension for the page and figures out which Application Server should process the page (In our case it will be ASP.NET).  2. ASP.NET reads the aspx file for the page and generates a class ( Order_aspx ) and a partial class ( Order) which contains the declarations for the form and its controls  3. The two partial classes ( Order, Order.aspx.vb ) and are compiled together and provide all the event handling needed for the entire page (yields the Order class dll) Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc. Slide 50

51 Processing an ASP.NET Application (B)   4. An Order_aspx file is generated by ASP.NET and compiled to another dll.  It contains all the code needed to initialize the given web page  Inherits the Order class – so any object instan-tiated from the Order_aspx class will contain  the code that creates the web page  the event handlers provided by the Order class  5. VB compiler is called to compile class files in the App_Code file producing another dll Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc. Slide 51

52 Processing an ASP.NET Application (C)   FINALLY – ASP.NETcreates an instance of the page and raises appropriate events  The events are processed by the event handlers for the page  HTML is generated and the page is rendered  To complete the round trip, the HTML page is passed back to the web server and on to the client side browser  Note that all dlls ( steps 1-4 ) are generated only the first time a page is called. They are cached. Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc. Slide 52

53 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 53

54 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 54

55 Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 55


Download ppt "Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1."

Similar presentations


Ads by Google