Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sergey Sidorov PhD student, computer software chair Computer Science department.

Similar presentations


Presentation on theme: "Sergey Sidorov PhD student, computer software chair Computer Science department."— Presentation transcript:

1 Sergey Sidorov PhD student, computer software chair Computer Science department

2 Agenda Introduction to ASP.NET Web Forms Summary

3 What is ASP.NET 3.5? An integrated suite of components that combines the building blocks of the Web Markup languages HTTP-with proven object-oriented methodolody

4 ASP.NET v.s. earlier web development platforms ASP.NET is completely object-oriented programming model ASP.NET gives ability to code in any.NET language ASP.NET is dedicated to high perfomance

5 7 Facts about ASP.NET 1. ASP.NET is integrated with the.NET Framework 2. ASP.NET is compiled, not interpreted 3. ASP.NET is Multilanguage 4. ASP.NET is hosted by the Common Language Runtime 5. ASP.NET is object-oriented 6. ASP.NET is multidevice and multibrowser 7. ASP.NET is easy to deploy and configure

6 7 Facts about ASP.NET

7

8 Releases of ASP.NET 1.0 1.1 2.0 3.5

9 ASP.NET 2.0 More rich controls (more than 40 new controls) Master pages (reusable page template) Themes (defining appearance characteristics) Security and memberships Data source controls (easy binding custom data container) Profilers (store user-specific info in database)

10 ASP.NET 3.5 LINQ and AJAX LINQ (Language integrated query) Allows to write C# or Visual Basic code that manipulated in-memory data in muсh the same way query a database AJAX (Asynchronous JavaScript and XML) Programming asynchronous requests from client part to server

11 Difference of ASP.NET AJAX

12 ASP.NET 3.5

13 ASP.NET files descriptions.aspx – web pages (user interface and application code).ascx – user controls..asmx or.svc – ASP.NET web services web.config – XML-based configuration file global.asax – global application file.cs – code-behind files that contain C# code

14 How a page class is considered?

15 Web Forms

16 ASP.NET pages officially known as web forms A vital part of ASP.NET application Page processing Web application executes on server Web applications are stateless

17 HTML forms

18

19 User click the submit button, Browser collects values of controls, Pastes it together in a long string, String is sent back using HTTP POST operation, In our case

20 HTML forms You can look up by values in the Request.Form In our case

21 Dynamic User Interface Almost all web control properties are readable and writable An easier way to add a Label Updating its properties

22 Advantages of second case It is much easier to write Control-based code is much easier to place inside page Control model hides the low-level HTML details

23 The ASP.NET Event Model Your page runs for the first time. ASP.NET creates page and controls objects, initialization code executes, Page is rendered to HTML and returned to the client Page objects are released from server memory

24 ASP.NET Event Model User does something that triggers a postback Page is submitted with all page data ASP.NET intercepts the returned page and re-create the page objects Taking care to return them to the last state ASP.NET raises events (such as Button.Click) Performing server side operation Modified page is rendered to HTML and returned to the client

25 View state The next time the page is posted back, ASP.NET follows these steps: Re-create the page and control objects based on defaults Desirialize the view information and updates all the controls Adjusting the page according to the posted back date Event-handling code can get involved

26 View state

27

28 XHTML Compliance ASP.NET 3.5 web controls are compliant with XHTML 1.1. standard XHTML 1.1. doesn’t add any functionality in your page XHTML 1.1. allows to validate errors Valid XML documents

29 Document Type Definition Every XHTML document should begin with a doctype (document type definition)

30 Web Forms Processing Stages Page framework initialization User code initialization Validation Event handling Automatic data binding Cleanup

31 Web Form Processing Stages

32 Page Framework Initialization ASP.NET first creates a page It generates all controls If it is not firs request Desterilize view state information and applies it to the page Page.Init event is fired ( rarely handed) it is too early

33 User Code Utilization Page.Load event is fired Page.Load event is always fired. (not only in first case) IsPostBack property of page

34 Validation ASP.NET includes validation controls that can automatically validate other user input controls and display error messages Events fire after page loaded but before any other events take place You can use Page.IsValid property

35 Event Handling 2 types of events Immediate response events: clicking button, image region Change events: changing selection in a control or the text in the textbox. Fire immediately if AutoPostBack is true. Otherwise they fire next time the page is posted back

36 Change Text, Click Button Page.Init Page.Load TextBox.TextChanged Button.Click Page.PreRender Page.Unload

37 Automatic Data Binding Using Data Source controls 2 types of data souse operation Before Page.PreRender (inserts, deletes updates) After Page.PreRender (Performing queries) filing data

38 Cleanup After rendering page to HTML PageUnload event is fired Page objects are available but page is rendered and can’t be changed

39 The Page As a Control Container Web form renders itself and then asks all the controls on page render themselves Each control can contain child controls Each is also responsible for their rendering code

40 The Page As a Control Container When ASP.NET first creates a page, it inspects the.aspx file. For each element with runat=“server” it creates and configured control object Adds this control as a child control of the page Page.Controls collects all page controls

41 Showing the Control Tree Rule don’t use Response.Write() Add this code to the Page.Load event

42 Showing the Control Tree

43 When you run this page you won’t see full list of controls

44 Showing the Control Tree ASP.NET adds LiteralControl objects LiteralControl objects don’t provide much in the way of functionality

45 Showing the Control Tree Showing all controls

46 Showing the Control Tree

47 Page Header You can transform any HTML element into server control with runat=“server” attribute Page can contain HTMLHead controls for access from server to tag Allows to change page rendering Title StyleSheet Controls

48 Page Header Example of changing parameters

49 Dynamic Control Creation Element is added to the end of collection To get more control use PlaceHolder – house of controls

50 Dynamic Control Creation Dynamics controls will exist until the next post back ASP.NET will not re-create dynamically added controls For recreation of control multiple time use Page.Load event (using View State)

51 Dynamic Control Creation Deleting Control Adding events handlers for dynamic controls

52 The Page Class All web pages are instances of ASP.NET Page class It is placed System.Web.UI namespase Useful properties Session Application Cache Request Responce Server User Trace

53 Session, Application and Cache Session stores any user-specific information that needs to persist between web-page request Storing: user name, ID, shopping card Application stores information that is global for all ASP.NET application Cashe stores global information. Provides much more scalable mechanism because ASP.NET can remove information from server

54 Request Represent the value and prototype of HTTP request Contains All URL parameters All information sent by client All information can be found in Control model You can use it for examining of Type browser Getting access to user cookies

55 Request

56

57

58 Response Presents web’s server response to a client request Doesn’t play nearly as central role Server.Transfer for redirect is qucker

59 Response

60 Responce

61

62 Server

63 MapPath() method converts relative path to the physical path HTML and URL encoding

64 User User object presents information about the user making request. You can authenticate the user making request based on Windows account information

65 Trace

66

67 Summary You learned: Introduction to ASP.NET Web Forms

68 Reference ASP.NET 3.5 in C# 2008


Download ppt "Sergey Sidorov PhD student, computer software chair Computer Science department."

Similar presentations


Ads by Google