1. Trang chủ
  2. » Giáo án - Bài giảng

Web application and asp net

238 6 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 238
Dung lượng 7,86 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Describe the following: Explain Active Server Pages Explain the features of ASP.NET... Web-enabled Application ArchitectureProxy Server Internet Web server Certificate Client 1 Browser

Trang 1

Chapter 1

Introduction to Web

Applications and ASP.NET

Trang 2

Describe the following:

Explain Active Server Pages

Explain the features of ASP.NET

Trang 3

Client 1

Client 2

Client/Server and Web Applications

ASP.NET and Webforms / Chapter 1/ Slide 3 of 22

Trang 4

Web-enabled Application Architecture

Proxy Server

Internet

Web server Certificate

Client 1

(Browser)

Database Server

server HTTP

Certificate Server

Server-based programs

ASP CGI ISAPI

Other servers

FTP SMTP Exchange Server

Trang 6

Network Interface and HTTP Service

Network Interface

Transport Layer

and

Internet

and Internet Layer (TCP / IP)

Windows Sockets

Trang 7

Accessing Database Information

Web server HTTP

Trang 8

Web Application Development Cycle

Designing the application

Planning the Web application

Constructing and testing the components of the application

Going live

Production and maintenance

Trang 9

Web Application Development Process

Functional specifications

No

Design phase

complete?

Design complete?

Yes

Complete?

Going live

Production and maintenance

No

Yes No

Yes

A

Trang 11

JavaScript data validationdata validation

Data valid?

Valid Data Submit data to serverto server

Yes

No

Trang 12

Client-Side Scripting

Provide user interaction

Dynamically change content

Validate dataIntegration

<script language="JavaScript">

JavaScript statements;

Trang 13

Active Server Pages

<HTML><BODY>

<CENTER><I><FONT COLOR="HOTPINK" size = 5>

<%If Time >= #12:00:00 AM# And Time < #12:00:00 PM# Then%>

"Now the time is between 12:00 am and 12:00 pm"

Trang 14

Processing of ASP File

Trang 15

Advantages of ASP

Trang 16

ASP File in a Web-based Application

Active ServerPages (ASP)JavaScriptVBScript

Active Server Pages (ASP)JavaScriptVBScript

Trang 17

Evolution of ASP.NET

Trang 19

Advantages of ASP.NET

Compiled pages improve execution speed

Supports strongly typed languages like C#, VB

Compiled pages improve execution speed

ASP code is separated from the HTML design

and text Provides declarative server controls

Trang 20

Advantages of ASP.NET (Contd.)

Supports re-use of code by the inheritance

An inbuilt method, Trace, helps to debug a page

Supports re-use of code by the inheritance

mechanism

No need to register component

Trang 21

Features of ASP.NET - 1

Adds functionality using C# or VB.NET

Uses server - side caching

ASP.NET

Ships with many in-built server controls

Recognizes the type of client browser and accordingly displays the contents to the client

Trang 22

Features of ASP.NET - 2

Refers hierarchical namespaces

Global.asax file holds

Global.asax file holds additional events

Web service - a function deployed and used over the Web

ASP.NET

Trang 23

Chapter 2

ASP.NET Objects

Trang 24

Explain the basics of ASP.NET

Discuss the process flow of an ASP.NET Page

Explain the Page_Load event

Explain the Page_Load event

Use the Request and Response objects

Trang 26

HTML Control

An ASP.NET Page– 2

Web Control

Trang 27

Starting with ASP.NET

Trang 28

<input type="button" id="Submit" runat="server" value="Click"/>

Trang 29

t sender,EventArgs e)

Trang 31

Page_Load Event

World

Trang 32

Process Flow

Execution on the server

HTTP Request

HTML

6

3

User causes Postback

4

LPage

Values

after

Postback

Changes are processed

7

HTMLPage

5

Trang 33

ASP.NET Objects -1

Trang 34

ASP.NET Objects –2

Trang 35

ASP.NET Objects – 3

Trang 36

Virtual Directories

Trang 37

Permissions

Trang 38

HTTP Protocol

HTTP Response HTTP

Request

Trang 39

Request and Response

Trang 40

Response.Redirect

Trang 41

Chapter 3

ASP.NET Controls

Trang 42

Explain Web controls

Identify the Object model

Use:

Use:

Discuss rich controls

Trang 43

Web Controls

ASP.NET

ASP.NET Controls

Trang 44

TextBox

Trang 45

Object Model - 2

<html><script language="C#" runat ="server" >

void click1(Object Src, EventArgs E){

<asp:textbox id="cur_obj" size = 40 runat="server"/> <br><br>

<asp:button type = submit text= "Say Hello!!!" OnClick="click1" runat =

"server" /><br>

</form>

</body>

</html>

Trang 47

<asp:textbox id="name" runat="server"/>

Text Entry - Intrinsic Control

Single-line entry

Multi-line entry

<asp:textbox id="add" textmode="multiline"

rows="5" columns="10" runat="server"/>

<asp:textbox id="pass" textmode="password"

runat="server"/>

Multi-line entry

Password entry

Trang 48

Control Transfer - Intrinsic Control

Navigate between the pages

Trang 49

Difference in Intrinsic Controls code

Trang 50

<asp:checkbox id = "chk1" Text = "have U selected me" runat="server"/>

<asp:radiobutton id ="rad1" Text =" button 1" groupname="radio" runat="server"/>

Selection - Intrinsic Control - 1

CheckBox

RadioButton

<asp:radiobutton id ="rad1" Text =" button 1" groupname="radio" runat="server"/>

<asp:radiobutton id ="rad2" Text =" button 2" groupname="radio" runat="server"/>

<asp:radiobutton id ="rad3" Text =" button 3" groupname="radio" runat="server"/>

<asp:listbox id="lb" runat="server"/>

<asp:dropdownlist id= "ddl" runat="server" />

ListBox

DropDownList

Trang 51

Data Populating Methods of

Selection Intrinsic Control

void Page_Load (Object Src, EventArgs E)

<asp:listbox id="lbs" runat="server">

<asp:ListItem> One </asp:ListItem>

<asp:ListItem> Two </asp:ListItem>

<asp:dropdownlist id= "ddl" runat="server" >

<asp:ListItem> One </asp:ListItem>

<asp:ListItem> Two </asp:ListItem>

<asp:ListItem> Three </asp:ListItem>

</asp:dropdownlist>

Trang 52

Container controls can contain other controls

One of the main uses of container controls is

that the visibility of a group of controls can be changed at one point by placing them in a

container control, and setting the property of

Container

<asp:panel id="pan" Visible="False" runat="server" >

<asp:textbox id="pass1" textmode="password" runat="server"/>

<asp:textbox id="pass2" textmode="password" runat="server"/>

</asp:panel>

container control, and setting the property of

the container control

Trang 53

Rich Controls

Used for changing

the advertisements

on the Web pages

Gives full functionality

of a calendar

Trang 54

Category assigned to the ad Priority of the advertisement

in the schedule of rotation

Trang 55

AdRotator - 2

Trang 56

Calendar control responds to two events:

Calendar Control

Trang 57

Chapter 4

Advanced Validation Techniques

Trang 58

Explore the various Validation controls

Explain code behind

Implement code behind

Trang 59

Validation Controls

Restricts blank fieldCompares two fieldsChecks for specified range

RequiredFieldValidator

CompareValidator

RangeValidator

Checks value with expression

Checks value of client-side

Trang 60

Inline error message

RequiredFieldValidator

entered

<asp:requiredfieldvalidator controltovalidate="userid"

display="static" errormessage="You must enter your user

id." runat=server>

The User Id cannot be left Blank!

</asp:requiredfieldvalidator>

Trang 61

Validation Error Message

Dynamic Display

Trang 62

< asp:comparevalidator controltovalidate="pwd_con" display="static" errormessage="the confirmation password does not match."

controltocompare="pwd" type ="String" operator="Equal"

runat=server> *

</ asp:comparevalidator > = , < , > , <= , >= , Not Equal

CompareValidator

< asp:comparevalidator controltovalidate="bid" display="static"

errormessage="You cannot enter a bid for lesser than $100.“

valuetocompare =100 type="Integer" operator="GreaterThanEqual"

Trang 63

< asp:rangevalidator controltovalidate="r3" type="Integer"

control for the range

Trang 64

Sign Meaning

^ The caret sign ^ specifies that checking starts from here

$ The “$” sign specifies that the checking ends here

[] Square brackets “[]” checks that the value entered match with any

RegularExpressionValidator - 1

[] Square brackets “[]” checks that the value entered match with any

of the characters that are in the square brackets.

\w “\w” allows any value to be entered

/d{} “/d” specifies that the value entered is a digit, and {} specifies the

number of occurrences of the specified data type

+ The + sign indicates that one or more elements to be added to the

expression being checked

Trang 66

<asp:customvalidator runat="server"

controltovalidate="grade"

clientvalidationfunction="clval"

Client-side function

CustomValidator

onservervalidate="serval" display="static">

Wrong value

</asp:customvalidator>

Trang 67

<asp:validationsummary id="vs1" headertext="The

errors found are: " displaymode="singleparagraph"

runat="server"/>

ValidationSummary

runat="server"/>

</asp:customvalidator>

Trang 68

Page.IsValid Property

<script language="C#" runat="server" >

void validate_page(Object Src, EventArgs E){

if (Page.IsValid == true) {

lbl.Text = "Page is Valid!";}

else {

lbl.Text = "Page is not Valid!"; }

lbl.Text = "Page is not Valid!"; }

}

</script>

Trang 69

Uplevel and Downlevel Browsers

<%@ Page ClientTarget=DownLevel %>

Disable

client-side validation

Trang 70

<%@ Page language="C#" Inherits="codeb" %>

<html>

<script language="C#" runat ="server" >

</script>

Provides the functionality

Trang 71

public System.Web.UI.WebControls.Button bMe;

protected void bMe_Click(Object sender, EventArgs e) {

lb1.Text = "Clicked!";

} void Main() {

}

}

Trang 72

Chapter 5

The Application And Server Objects

Trang 73

Discuss the Global.asax file

Explain events in Global.asax file

Use the Application object

Use the Application object

Use the Server object

Trang 74

Stored in the application’s root directory

Defines boundary of application

Initialize application or session level variables

Connect to databases

Send cookies

Trang 75

Session_OnStart Fired every time a new session begins.

Session_OnEnd Fired when the session ends Refer to the session on

the Session object for the various ways in which a session can end.

Trang 76

Events in Global.asax - 2

Trang 78

Application Object - 2

<script language="C#" runat="server">

void Application_OnStart(Object sender, EventArgs E) {

Application ["greeting"] = "Welcome to my World";

Trang 79

Application Object - 3

<script language="C#" runat="server">

void Application_OnStart(Object sender, EventArgs E) {

Application ["Counter"] = 0;

}</script>

<html>

<script Language ="C#" runat ="server" Debug = "true">

<script Language ="C#" runat ="server" Debug = "true">

void Page_Load(Object Src, EventArgs E){

Application["Counter"] = (Int32) Application ["Counter"] + 1;

Response.Write("You are visitor number :" + Application ["Counter"]);

}</script>

<form runat= "server" >

<MARQUEE BEHAVIOR="scroll" Scrolldelay = 25><FONT SIZE = 5

COLOR

= RED>Welcome to my World</FONT></MARQUEE>

</form></html>

Trang 80

Application Object - 4

Trang 81

Controlling Access

<HTML>

<script Language ="C#" runat ="server" Debug = "true">

void Page_Load(Object Src, EventArgs E)

Trang 82

<script language="C#" runat="server">

void Application_Start(Object sender, EventArgs E)

{ String [] job = new String [4];

job[0]= "Faculty"; job[1]= "Programmer";

job[2]= "Salesman"; job[3]= "Manager";

Application ["j"] = job; } </script>

<<HTML> <script Language ="C#" runat ="server" >

void Page_Load(Object Src, EventArgs E) {

Trang 84

Execute Method

<%@ Page Debug ="true"%><html>

<script language="C#" runat="server">

void clicked (Object Src, EventArgs E){

Server.Execute("/test/ses6ex1.aspx");}

</script>

<form runat ="server">

<form runat ="server">

<asp:button id = "btn1" onclick = "clicked" Text =" Click me to transfer execution" runat = "server" />

</form></html>

Trang 85

Transfer Method

Server.Transfer("/test/transfer.aspx");

Trang 87

ap.aspx"));

Trang 88

URLEncode Method - 2

<html>

<script language="C#" runat="server">

void clicked (Object Src, EventArgs E)

{

String name = Server.UrlEncode("John Saunders");

Response.Redirect

<html>

<script language="C#" runat="server">

void clicked (Object Src, EventArgs E)

<form runat ="server">

<asp:button id = "btn1" onclick = "clicked" Text =" Click me

to send values" runat = "server" />

<form runat ="server">

<asp:button id = "btn1" onclick = "clicked" Text =" Click me

to send values" runat = "server" />

</form>

</html>

Trang 89

URLEncode Method - 3

<html><script language="C#" runat="server">

void clicked (Object Src, EventArgs E){

String name = Server.UrlEncode("John Saunders");

String password = Server.UrlEncode("king");

Response.Redirect("http://localhost/code/error.aspx?name=" + name + " &password=" + password);

}</script>

<html><script language="C#" runat="server">

void clicked (Object Src, EventArgs E){

String name = Server.UrlEncode("John Saunders");

String password = Server.UrlEncode("king");

Response.Redirect("http://localhost/code/error.aspx?name=" + name + " &password=" + password);

}</script>

}</script>

<form runat ="server">

<asp:button id = "btn1" onclick = "clicked" Text =" Click me to send values" runat = "server" />

</form></html>

}</script>

<form runat ="server">

<asp:button id = "btn1" onclick = "clicked" Text =" Click me to send values" runat = "server" />

</form></html>

Trang 91

Chapter 6 6

The Session Object

Trang 92

Describe Cookies

Read and write Cookies

Explain the use of session object

Define stateliness of a session

Trang 93

Cookies - 1

A cookie is a small packet of information that is

used to maintain information on the user's

computer A cookie can be temporary or

persistent

Expires when

the user leaves

the Web site

Retained on the clientmachine and can be read bythe Web server when theuser next accesses the Website

Trang 96

Retrieving Data - 1

HttpCookie cookie = Request.Cookies[“cookiename”];

<html><script language="C#" runat="server">

void Page_Load(Object Sender, EventArgs E){

HttpCookie cookie1 = new HttpCookie("UserName");

DateTime dt = DateTime.Now;

TimeSpan ts = new TimeSpan(0,0,1,0);

cookie1.Expires = dt.Add(ts);

Response.Cookies.Add(cookie1);

Trang 97

<asp:Label id = "Display1" runat="server" /><br><br>

<asp:Label id = "Display2" runat="server" />

</html>

Ngày đăng: 21/03/2021, 18:50

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN