web engineering 2(lect 2)

29
Web Engineering-II Web Engineering-II By; By; Roohul Amin Mashwani Roohul Amin Mashwani

Upload: roohul-amin

Post on 06-Dec-2014

742 views

Category:

Education


3 download

DESCRIPTION

Download it free...

TRANSCRIPT

Page 1: Web engineering 2(lect 2)

Web Engineering-IIWeb Engineering-IIBy;By;

Roohul Amin MashwaniRoohul Amin Mashwani

Page 2: Web engineering 2(lect 2)

Introduction to ASP.NET Introduction to ASP.NET 3.53.5

►HTML Forms to NowhereHTML Forms to Nowhere►Try This: HTML Data Entry with No ExitTry This: HTML Data Entry with No Exit

Your Browser Is a Thin ClientYour Browser Is a Thin Client A Protocol Without a Country: Stateless HTTPA Protocol Without a Country: Stateless HTTP

►ASP.NET 3.5 as an Alternative to CGIASP.NET 3.5 as an Alternative to CGI►From Client Side to Server SideFrom Client Side to Server Side► .NET Organization.NET Organization

Development ContextsDevelopment Contexts

Page 3: Web engineering 2(lect 2)

Cont…Cont… Running ASP.NET Files on Your Computer Running ASP.NET Files on Your Computer

or LANor LAN ASP.NET in the Real WorldASP.NET in the Real World Language Partners with ASP.NETLanguage Partners with ASP.NET

Page 4: Web engineering 2(lect 2)

Introduction to ASP.NET 3.5Introduction to ASP.NET 3.5► In getting started with ASP.NET, you’re In getting started with ASP.NET, you’re

entering the world of server-side entering the world of server-side programming.programming.

► If you’re familiar with languages like PHP If you’re familiar with languages like PHP you already have some idea of what can you already have some idea of what can be done with server-side processing.be done with server-side processing.

►You will find that ASP.NET has a lot in You will find that ASP.NET has a lot in common with HTML.common with HTML.

Page 5: Web engineering 2(lect 2)

HTML Forms to NowhereHTML Forms to Nowhere► In many respects the HTML tags available In many respects the HTML tags available

to create data input are a confusing and to create data input are a confusing and frustrating exercise in futility.frustrating exercise in futility.

►Users can enter information for Users can enter information for everything from responses to a everything from responses to a questionnaire to an order for a product.questionnaire to an order for a product.

►Using a handy submit button, also Using a handy submit button, also available in HTML, you can then send the available in HTML, you can then send the information to absolutely information to absolutely nowhere.nowhere.

Page 6: Web engineering 2(lect 2)

HTML Data Entry with No ExitHTML Data Entry with No Exit►Open your favorite text editor, Notepad Open your favorite text editor, Notepad

will suffice, and paste the following HTML will suffice, and paste the following HTML code.code.

►Save the document as Save the document as nowhere.htmlnowhere.html..►Next, open the HTML file in your browser.Next, open the HTML file in your browser.►The following HTML code will set up a The following HTML code will set up a

perfectly clear HTML form that sends perfectly clear HTML form that sends information into the ether:information into the ether:

Page 7: Web engineering 2(lect 2)

<html><head><title>HTML to Nowhere</title></head><body><form>Please enter your name:<br/><input type="text" name="username"/><p/>Press the button to receive all of your hopes and dreams:<br/><input type="submit" value="Dream Button" /></form></body></html>

Page 8: Web engineering 2(lect 2)

Cont…Cont…►When you test the code after you When you test the code after you

enter your name and click the Dream enter your name and click the Dream Button your output will look just like;Button your output will look just like;

Page 9: Web engineering 2(lect 2)

OutputOutput

HTML data entry and submit form

Page 10: Web engineering 2(lect 2)

Cont…Cont…►Without some kind of mechanism to Without some kind of mechanism to

capture and store the information or capture and store the information or pass it on to somewhere else, HTML pass it on to somewhere else, HTML can’t do.can’t do.

►What ASP.NET 3.5 offers is a way to What ASP.NET 3.5 offers is a way to store, retrieve, and process the store, retrieve, and process the information.information.

Page 11: Web engineering 2(lect 2)

Your Browser Is a Thin ClientYour Browser Is a Thin Client►Your browser’s main job is requesting Your browser’s main job is requesting

pages from the server and displaying pages from the server and displaying what the server has processed.what the server has processed.

►Using HTTP as a transfer protocol, your Using HTTP as a transfer protocol, your browser parses (interprets) the HTML browser parses (interprets) the HTML code it gets from the server but code it gets from the server but otherwise does little processing.otherwise does little processing.

Page 12: Web engineering 2(lect 2)

Cont…Cont…►Because your HTTP client (browser) Because your HTTP client (browser)

leaves most of the processing work to leaves most of the processing work to the server, it is considered a the server, it is considered a thin client.thin client.

►There’s nothing wrong with a thin client, There’s nothing wrong with a thin client, and it can process JavaScript, Flash, etc.and it can process JavaScript, Flash, etc.

►With plug-ins, which virtually all With plug-ins, which virtually all browsers have built in.browsers have built in.

Page 13: Web engineering 2(lect 2)

A Protocol Without a Country: A Protocol Without a Country: Stateless HTTPStateless HTTP

►HTTP client browser is HTTP client browser is stateless.stateless.►As soon as a web page reaches your As soon as a web page reaches your

computer, the connection between computer, the connection between your browser and the server is broken.your browser and the server is broken.

►The browser does not remember the The browser does not remember the last page—it does not hold last page—it does not hold state.state.

►As next page arrives, it does not As next page arrives, it does not remember the last page.remember the last page.

Page 14: Web engineering 2(lect 2)

Cont…Cont…►The ASP.NET environment lets you The ASP.NET environment lets you

move from a stateless HTTP move from a stateless HTTP environment to a state-preserved one.environment to a state-preserved one.

Page 15: Web engineering 2(lect 2)

ASP.NET 3.5 as an ASP.NET 3.5 as an Alternative to CGIAlternative to CGI

►Microsoft’s alternative to a Common Microsoft’s alternative to a Common Gateway Interface (CGI) is ASP.NET, Gateway Interface (CGI) is ASP.NET, now in version 3.5.now in version 3.5.

►As a unified web platform, ASP.NET As a unified web platform, ASP.NET provides what you need to develop provides what you need to develop applications that hold state and use applications that hold state and use the information that you put into the the information that you put into the HTML form.HTML form.

Page 16: Web engineering 2(lect 2)

Cont…Cont…►Usually, when we think of saving state, Usually, when we think of saving state,

we imagine writing the data to a we imagine writing the data to a storage device like a hard drive. Using storage device like a hard drive. Using a word processor, every time you save a word processor, every time you save your file, you save its state.your file, you save its state.

►Using ASP.NET, you can do the same Using ASP.NET, you can do the same thing with information from thing with information from anyone anyone who uses your web application.who uses your web application.

Page 17: Web engineering 2(lect 2)

Cont…Cont…►Microsoft’s web server, Internet Microsoft’s web server, Internet

Information Services (IIS), uses the Information Services (IIS), uses the Internet Server API (ISAPI)Internet Server API (ISAPI)

►ASP.NET is as a request processing ASP.NET is as a request processing engine that takes incoming requests engine that takes incoming requests and sends them to a point where you and sends them to a point where you can attach your C# script to process can attach your C# script to process the request.the request.

Page 18: Web engineering 2(lect 2)

Cont…Cont…►Both C# and Visual Basic.NET Both C# and Visual Basic.NET

(VB.NET) are languages for creating (VB.NET) are languages for creating managed code that is efficiently run in managed code that is efficiently run in the .NET environment.the .NET environment.

►Microsoft .NET framework, means an Microsoft .NET framework, means an application is executed by a virtual application is executed by a virtual machine rather than by your own machine rather than by your own processor.processor.

Page 19: Web engineering 2(lect 2)

From Client Side to Server From Client Side to Server SideSide

Browser

ASPX file

Server-Server executescode; resultsconverted to HTMLand returned to client

Data reference to ASPX file

Returns HTML

ClientWeb Server

Server-side script

runat="server"

Page 20: Web engineering 2(lect 2)

Cont…Cont…►The example we’ll look at is saved in an The example we’ll look at is saved in an

ASP.NET file named Dreamer.aspx.ASP.NET file named Dreamer.aspx.► In the Dreamer.aspx file, the <form> In the Dreamer.aspx file, the <form>

container includes an input text window container includes an input text window just like the HTML file-to-nowhere file, just like the HTML file-to-nowhere file, with only a slightly different format:with only a slightly different format: Default.aspx-------saveDefault.aspx-------save Dreamer.aspx.cs-------save asDreamer.aspx.cs-------save as

Page 21: Web engineering 2(lect 2)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Dreamer.aspx.cs" Inherits="_Dreamer" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"><title>Server Side Dreamer</title></head><body><form id="form1" runat="server"><div> Please enter your name:<br /><asp:TextBox ID="DreamBox" runat="server"> </asp:TextBox><p />Press the button to receive all of your hopes and dreams:<br /><asp:Button ID="Dreamer“ runat="server“ Text="Dream Button"OnClick="DoDream" /><p /><asp:Label ID="Dreams" runat="server"Text="Dreams Here"></asp:Label></div></form></body></html>

Example of A Dynamic Website

Page 22: Web engineering 2(lect 2)

using System;using System.Data;using System.Configuration;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Xml.Linq;public partial class _Dreamer : System.Web.UI.Page{protected void DoDream(object sender, EventArgs e){Dreams.Text = DreamBox.Text + "'s dreams are big ones!";}}

Dreamer.aspx.cs

Page 23: Web engineering 2(lect 2)

OutputOutput

Page 24: Web engineering 2(lect 2)

.NET Organization.NET Organization► .NET is as a big control system with .NET is as a big control system with

two key elements.two key elements. .NET framework class library..NET framework class library. .NET .NET common language runtime.

Page 25: Web engineering 2(lect 2)

Cont…Cont…► .NET framework class library..NET framework class library. This library has thousands of classes organized This library has thousands of classes organized

into into namespaces.namespaces. This library is a repository of reusable types for This library is a repository of reusable types for

object-oriented development.object-oriented development. For example, For example, System.Web.UI NamespaceSystem.Web.UI Namespace

allows you to create several different ASP.NET allows you to create several different ASP.NET server controls and user interfaces.server controls and user interfaces.

Each namespace contains a collection of Each namespace contains a collection of classes.classes.

Page 26: Web engineering 2(lect 2)

Cont…Cont… The following represent a The following represent a few few of the of the

classes in this namespace:classes in this namespace: ● ● ControlControl ● ● Data BinderData Binder ● ● PageParserPageParser ● ● UserControlUserControl To use the classes as well as other To use the classes as well as other

structures such as interfaces, you need to structures such as interfaces, you need to include the namespace in your program.include the namespace in your program.

Page 27: Web engineering 2(lect 2)

Cont…Cont…► .NET .NET common language runtime. The runtime is a management agent for The runtime is a management agent for

code as it executes.code as it executes.

Page 28: Web engineering 2(lect 2)

Online Help for IISOnline Help for IIS►Click Help or Online Help from within Click Help or Online Help from within

IIS Manager to view the product IIS Manager to view the product documentation. documentation.

►View the View the IIS Operations Guide online. online.►Visit the official Visit the official Microsoft IIS website to website to

interact with the community and learn interact with the community and learn about IIS features.about IIS features.

Page 29: Web engineering 2(lect 2)

Thank You All!