introduction to asp.net and asp.net web forms

44
1

Upload: mindtree-campus

Post on 06-Mar-2016

249 views

Category:

Documents


3 download

DESCRIPTION

Introduction to ASP.NET and ASP.NET Web Forms

TRANSCRIPT

Page 1: Introduction to ASP.NET and ASP.NET Web Forms

1

Page 2: Introduction to ASP.NET and ASP.NET Web Forms

2

Page 3: Introduction to ASP.NET and ASP.NET Web Forms

3

Page 4: Introduction to ASP.NET and ASP.NET Web Forms

1. Author writes HTML.

2. The Web browser sends a request for a particular Web page of a Web site to the Web server hosting that site. 3. The Web server searches for the page in directory containing Web pages for the Web site.

4. On finding the requested page, the Web server collects the HTML of the Web page. 5. The Web server sends the HTML to the requesting browser which then parses it to develop the visual presentation of the page.

4

Page 5: Introduction to ASP.NET and ASP.NET Web Forms

5

Page 6: Introduction to ASP.NET and ASP.NET Web Forms

1. The Web browser sends a request for a particular Web page of a Web site to the Web server hosting that site.

2. The Web server searches for the page in directory containing Web pages for the Web site.

3. On finding the requested page, the Web server collects the content (code + HTML) of the Web page.

4. The Web server then parses the content to produce HTML.

5. The HTML stream is sent back to the requesting browser which then parses it to develop the visual presentation of the page.

6

Page 7: Introduction to ASP.NET and ASP.NET Web Forms

7

Page 8: Introduction to ASP.NET and ASP.NET Web Forms

ASP is a COM (Component Object Model) based technology.

The ASP component (asp.dll) attaches itself with the IIS (Internet Information Server).

Upon receiving a request for an ASP page (.asp), IIS redirects it to the asp.dll.

The asp.dll parses the ASP page for any script within it and if found, combines it with the HTML code and returns it to IIS which then forwards it to the requesting browser.

8

Page 9: Introduction to ASP.NET and ASP.NET Web Forms

9

Page 10: Introduction to ASP.NET and ASP.NET Web Forms

10

Page 11: Introduction to ASP.NET and ASP.NET Web Forms

11

Page 12: Introduction to ASP.NET and ASP.NET Web Forms

12

Page 13: Introduction to ASP.NET and ASP.NET Web Forms

13

Page 14: Introduction to ASP.NET and ASP.NET Web Forms

14

Page 15: Introduction to ASP.NET and ASP.NET Web Forms

15

Page 16: Introduction to ASP.NET and ASP.NET Web Forms

16

Page 17: Introduction to ASP.NET and ASP.NET Web Forms

17

Page 18: Introduction to ASP.NET and ASP.NET Web Forms

18

Page 19: Introduction to ASP.NET and ASP.NET Web Forms

Notes:

Page.Request: It receives the HttpRequest object for the requested page. HttpRequestobject has information about the current HTTP request.

Page.response: It receives the HttpResponse object associated with the Page object. Through this object, you can send HTTP response data to a client. It has information about that response.

Page.IsPostBack: It returns a a value indicating if the page is being loaded for the first time or whether it is being loaded in response to a client postback

UICulture: This is the User Interface culture and is a property of the executing thread

19

Page 20: Introduction to ASP.NET and ASP.NET Web Forms

Notes:

Control.UniqueID: Gets the unique, hierarchically qualified identifier for the server control.

BaseValidator.Validate: Performs validation on the associated input control and updates the Is Valid property.

IValidator.IsValid Property: When implemented by a class, gets or sets a value indicating whether the user-entered content in the specified control passes validation.

20

Page 21: Introduction to ASP.NET and ASP.NET Web Forms

Notes:

Control.Render Method sends server control content to a provided HtmlTextWriterobject, which writes the content to be rendered on the client.

HttpResponse.OutputStream Property: Enables binary output to the outgoing HTTP content body.

21

Page 22: Introduction to ASP.NET and ASP.NET Web Forms

Notes:

ASP.NET Page life cycle events are as follows:

PreInit: This event is used to check whether the page being processed is being requested for the first time, using IsPostBack property

Init: This event is used to read or initialize the control properties.

InitComplete: This event is raised by the Page object. This event is used to complete all tasks that require initialization

PreLoad: This event is used to perform any processing on the page or control before the load event occurs

Load: In this event, the Page calls the OnLoad event method on the Page, and then does the same for each child control, till the page and all controls are loaded

Control events: These events are used to handle specific control events such as click event of the Button, or Text Changes event for the TextBox control

LoadComplete: This event is used to complete the tasks that require all other controls on the page be loaded

PreRender: The Page object calls EnsureChildControls for each control and for the page.

SaveStateComplete In this event any changes to the page or controls will be ignored, as the ViewState for the page and the controls has been already saved

Render: This is not an event . At this stage of the lifecycle of the page, the page calls all this method on each control.

Unload: This event occurs for each control and then for the page. This event can also be used to close control-specific database connections.

Note: The page life cycle events described here and in the subsequent slides have been referred from: http://msdn2.microsoft.com/en-us/library/ms178472.aspx

22

Page 23: Introduction to ASP.NET and ASP.NET Web Forms

Notes:

Init: Server controls should perform any initialization steps that are required to create and set up an instance. You cannot use view-state information within this event; it is not populated yet. You should not access another server control during this event, regardless of whether it is a child or parent to this control. Other server controls are not certain to be created and ready for access.

23

Page 24: Introduction to ASP.NET and ASP.NET Web Forms

Notes

ViewState:

Web Forms pages provide the ViewState property as a built-in structure for automatically retaining values between multiple requests for the same page.

This will be dealt with in detail in a later presentation (4.5 State Management).

24

Page 25: Introduction to ASP.NET and ASP.NET Web Forms

25

Page 26: Introduction to ASP.NET and ASP.NET Web Forms

Control.EnsureChildControls Method:

It determines whether the server control contains child controls. If it does not, it creates child controls.

DataSourcID:

Gets or sets the ID of the control from which the data-bound control retrieves its list of data items.

Control.DataBind Method:

Binds a data source to the invoked server control and all its child controls.

26

Page 27: Introduction to ASP.NET and ASP.NET Web Forms

27

Page 28: Introduction to ASP.NET and ASP.NET Web Forms

28

Page 29: Introduction to ASP.NET and ASP.NET Web Forms

Review the points on the slide, and provide the following elaboration to each point:

Easy Programming Model: HTML-like style of declarative programming of Server controls lets you build great pages with very less code than with classic ASP. All Web browsers support ASP.NET page -- including Netscape, Opera, AOL, and Internet Explorer

Flexible Language Options: More than 25 .NET languages are supported by ASP.NET. This gives flexibility in choice of language

Rich Class Framework: Over 4500 classes and more that encapsulate rich functionality like XML, data access, file uploading, regular expressions, image generation, performance monitoring and logging, transactions, message queuing, SMTP mail are available in .NET Framework

Compiled Execution: ASP.NET application is up to date due to dynamic compilation, and this compiled execution makes the application fast

Rich Output Caching: Rendering of controls to XHTML is improved by output caching. Database caching enables the application to be notified when the underlying database changes, eliminating unnecessary queries

Web-Farm Session State: In a Web farm, ASP.NET session state lets you share session data and user-specific state values across all machines. A Web Farm comprises of multiple Web servers situated on different machines having the same Web Application running on them.It is used for scaling up to increasing number of users and provide satisfactory response times.

Enhanced Reliability:

Master Pages - Using Master Pages, ASP.NET makes it easy to create and apply a common look-and-feel to your Web site. It ensures that the application is always available to users by automatically detecting and recovering from errors like deadlocks and memory leaks.

Themes: Using Themes, Web pages can be given a consistent appearance with the built-in support.

XHTML ComplianceUsing ASP.NET, XHTML-compliant pages can be easily created.

Improved Security ASP.NET helps you protect your data and users.

Built-in Protection ASP.NET has built-in protection from many common forms of hacker attacks, including cross-site scripting and more.

XML Web Services: ASP.NET makes exposing and calling XML Web Services simple. XML Web services allow applications to share data and communicate with other application over the Internet, irrespective of the type of operating system or programming language.

Improved Performance and Scalability: ASP.NET lets you use serve more users with the same hardware.

29

Page 30: Introduction to ASP.NET and ASP.NET Web Forms

Web Server :

Is a computer connected to the Internet or an intranet, based on where the web application resides and the purpose of the application.

When a URL is typed in the address bar of the browser, the browser sends a request to the server which then fetches the required page and sends it to your browser.

Example:

http://myservername/myApp/Default.aspx

When the above URL is typed in a browser, the browser sends a request to the server in this case “myservername”, which then fetches the required page “Default.aspx” from the web application “myapp” and then sends it to the browser.

30

Page 31: Introduction to ASP.NET and ASP.NET Web Forms

The main content folder of IIS is Inetpub directory. The content directories for each service are installed under this directory.

All the other services of IIS depend on the IIS Admin Service. Service. If this service is stopped, all other IIS services also stop

31

Page 32: Introduction to ASP.NET and ASP.NET Web Forms

32

Page 33: Introduction to ASP.NET and ASP.NET Web Forms

33

Page 34: Introduction to ASP.NET and ASP.NET Web Forms

IIS MMC can be opened also by:

Start ->Run -> inetmgr -> OK

34

Page 35: Introduction to ASP.NET and ASP.NET Web Forms

35

Page 36: Introduction to ASP.NET and ASP.NET Web Forms

To confirm that the application was created, right-click the new virtual directory, and then click Properties.

On the Virtual Directory tab, ensure that the virtual directory name is listed in the Application Name box under Application Settings.

If it is not, click Create.

The application name need not match the virtual directory alias.

36

Page 37: Introduction to ASP.NET and ASP.NET Web Forms

37

Page 38: Introduction to ASP.NET and ASP.NET Web Forms

38

Page 39: Introduction to ASP.NET and ASP.NET Web Forms

39

Page 40: Introduction to ASP.NET and ASP.NET Web Forms

40

Page 41: Introduction to ASP.NET and ASP.NET Web Forms

41

Page 42: Introduction to ASP.NET and ASP.NET Web Forms

42

Page 43: Introduction to ASP.NET and ASP.NET Web Forms

Reference

43

Page 44: Introduction to ASP.NET and ASP.NET Web Forms

44