Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts...

10
Introduction to ASP.NET 1 Introduction to ASP.NET

Transcript of Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts...

Page 1: Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.

Introduction to ASP.NET 1

Introduction to ASP.NET

Page 2: Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.

Introduction to ASP.NET 2

Web applications in general

• Web applications are divided into two parts– The server part– The client part

• The server part is usually programmed as “extensions” to an HTTP server (aka web server)

• The client part is usually executed by a web browser

• The HTTP protocol is used for communication between the client and the server

Page 3: Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.

Introduction to ASP.NET 3

Some web application frameworks

• Sun/Oracle Java Servlets + JSP

• PHP

• CGI (Common Gateway Interface)– Very old

• Ruby on Rails

• Microsoft ASP.NET

• Microsoft ASP– From before ASP.NET

Page 4: Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.

Introduction to ASP.NET 4

ASP.NET web applications

• ASP.NET is Microsoft’s way of making web application

• ASP.NET is programmed using a programming language– Usually VB.Net or C#

• The web server is usually Microsoft IIS– Internet Information Service

Page 5: Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.

Introduction to ASP.NET 5

ASP.NET

• ASP.NET is executed on the server side

• ASP.NET produces HTML, JavaScript,etc. to be shown / executed on the client side– By the browser

Page 6: Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.

Introduction to ASP.NET 6

Controls

• ASP.NET pages consists of– Pure HTML– Forms

• To accept user input

– Code• Usually written in VB.NET or C#

– Controls

• Code + controls are executed on the server producing HTML, JavaScript, etc.

Page 7: Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.

Introduction to ASP.NET 7

Postback

• Forms– Accept user input– Data is sent back to the same ASP.NET page

• Using HTTP POST request• Called postback

• Sometimes the ASP.NET pages wants to know if it’s executing a first request or postback

Page 8: Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.

Introduction to ASP.NET 8

Events

• Many ASP.NET controls sends events– Button has a ”button_click” event, etc.– Page has ”page_load” event, etc.– TextBox has ”textChanged” event

• Event handlers (methods) are usually placed in the codebehind file

• Event code are executed at the server– Events generate a HTTP request/response

Page 9: Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.

Introduction to ASP.NET 9

viewState

• HTTP is stateless

• ASP.NET keeps track of the state between postbacks– Hidden FORM field where the state of other

FORM fields is kept– Encoded, but not encrypted– Decoded at the server side

Page 10: Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.

Introduction to ASP.NET 10

Code behind / beside

• ASP.NET pages are generally split into two parts– View

• HTML + controls

– Code• Often called “code behind” or “code beside”• Event handlers

• Separation of concerns

• C# syntax: Partial class