1 presented by bikash shrestha. 2 what is asp.net or asp+? asp.net/asp+ is a programming framework...

33
1 Presented by Bikash Shrestha

Upload: erica-ross

Post on 26-Dec-2015

225 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

1

Presented by Bikash Shrestha

Page 2: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

2

What is ASP.NET or ASP+?

ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used on a server to build powerful Web applications.

Page 3: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

3

.NET Architecture

Page 4: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

4

What is ASP.Net?

Next generation of ASP New paradigm for server side

scripting Part of new .net framework

Page 5: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

5

Why ASP.NET?

Easy Programming Model Avoids spaghetti code Great pages with far less code than ASP Easy display data Easy validating user input Easy uploading files Works in all browser ( including

Netscape, Opera, AOL, and IE)

Page 6: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

6

Why ASP.NET?

Flexible Language Options ASP support VBScript and Jscript ASP.NET supports 25 .NET languages Includes built in support for VB.NET, C+

+, C#, and JScript.NET

Page 7: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

7

Why ASP.NET?

Rich Class Framework .NET Framework offers over 4500

classes that encapsulates rich functionality like

XML, data access, file upload, regular expressions, image generation, performance monitoring and logging, transactions, message queuing, SMTP mail, and more

Page 8: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

8

Why ASP.NET?

Improved performance & Scalability 3 to 5 times faster than ASP

Due to dynamic compilation

Rich Output Caching Eliminates the need to query the database

on every request improve performance of data-driven

pages

Page 9: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

9

Compatibility

Not fully compatible with ASP, however can run side by side with older versions.

Instead of .asp it uses .aspx extensions.

Page 10: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

10

Syntax and Semantics

ASP.NET fully API-compatible with traditional ASP except Request() Request.QueryString() Request.Form()

ASP.NET returns string ASP returns array of strings

Page 11: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

11

For ASP.NET

Cnn.com/Test.aspx?value=45&value=600

would be accessed as follows: <% ' Below line outputs: "45, 600"

Response.Write(Request.QueryString("values"))

' Below line outputs: "45" Response.Write(Request.QueryString.GetValues("values")(0)) %>

Page 12: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

12

Syntax & Semantics

ASP.NET pages support only a single language.

ASP.NET page functions must be declared in <script runat=server> blocks unlike <% %> in ASP.

Page 13: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

13

Syntax & Semantics

Page-render functions are not supported

Example IN ASP <% Sub RenderSomething() %>

<font color="red"> Here is the time: <%=Now %> </font> <% End Sub %> <% RenderSomething

RenderSomething %>

Page 14: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

14

Syntax & Semantics

Example IN ASP.NET<script language="VB" runat=server> Sub RenderSomething()

Response.Write("<font color=red> ") Response.Write("Here is the time: " &

Now) End Sub </script>

<% RenderSomething() RenderSomething() %>

Page 15: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

15

Display Hello World in ASP.NET

Save the file as an .aspx extension

<html> <body bgcolor="yellow">

<center> <h2>Hello W3Schools!</h2> </center>

</body> </html> first aspx code to display "hello world"

Page 16: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

16

Limitation of Classic ASP

Code has to be placed where the output apprears Impossible to separate ASP code from HTML Eg. <html>

<body bgcolor="yellow"> <center> <h2>Hello W3Schools!</h2>

<p><%Response.Write(now())%></p> </center> </body>

</html>

Page 17: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

17

ASP .NET - Server Controls

The "spaghetti-code" problem solved with server controls.

Server controls are tags that are understood by the server.

Three kinds of server controls: HTML Server Controls - Traditional HTML tags Web Server Controls - New ASP .NET tags Validation Server Controls - For input validation

Page 18: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

18

HTML Server Controls

HTML tags understood by server.

Comparable to JavaScript but run at server

Regular HTML elements are, by default, treated as text.

Add runat="server" to HTML elements to make it programmable and to be run at server.

must be within a <form> tag

id attribute is added to identify the server control

They can be used at a run time.

Page 19: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

19

Example of HTML Server Control

<script runat="server"> Sub Page_Load

link1.HRef="http://www.w3schools.com" End Sub

</script>

<html> <body> <form runat="server"> <a id="link1" runat="server">Visit W3Schools!</a> </form> </body>

</html> anchor example

Page 20: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

20

HTML Server Control contd…

HTMLButtonHTMLImage 2HTMLInputbuttonHTMLInputCheckboxHTMLInputHiddenHTMLInputImageHTMLInputRadiobuttonHTMLTableHTMLTextarea

Page 21: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

21

ASP .NET - Web Server Controls

ASP .NET tags understood by the server

Like HTML Server Controls, require runat="server" to execute in server

Like HTML Server Controls, require id.

Does not map to HTML Elements.

More complex elements

Page 22: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

22

ASP .NET - Web Server Controls contd…

AdRotator

Calendar

CheckboxList

DropdownList

Hyperlink

Image

Label

Listbox

Literal

Panel

RadiobuttonList

Table

Page 23: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

23

ASP .NET - Validation Server Controls

Used to validate user-input

If invalid data, display an error message to the user

By default, page validation performed when Button, ImageButton, or LinkButton control is clicked

Prevent validation by changing CausesValidation property to false.

Page 24: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

24

ASP .NET - Validation Server Controls contd…

CompareValidator

CustomValidator

RangeValidator

RegularExpressionValidator

RequiredFieldValidator

Validationsummary

Page 25: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

25

ASP .NET - Events

An Event Handler is a subroutine that executes code for a given event.

Example of The page load event

Example of The Page.IsPostBack Property

Page 26: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

26

ASP .NET Web Forms

All server controls must appear within a <form runat="server" > tag

By default the page is submitted to itself. If action is set then method=“post “ by default as in

Classic ASP An .aspx page can only contain ONE

<form runat="server"> control! Submitting a Form

Example Self Posting

Page 27: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

27

ASP.NET Data Binding

Data binding is used to fill lists with selectable items from an imported data source, like a database, an XML file, or a script.

Usually uses an imported source. the data is separated from the HTML any changes to the items are made in the separate

data source.

The following controls support data binding asp:RadioButtonList asp:CheckBoxList asp:DropDownList asp:Listbox

Page 28: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

28

Data Binding - ArrayList Object

The ArrayList object is a collection of items containing a single data value.

Example - ArrayList RadioButtonList

Page 29: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

29

Data Binding - The Hashtable Object

The Hashtable object contains items in key/value pairs.

Cannot sort items.

Example- Hashtable DropDownList

A Hashtable object may automatically generate the text and values to the following controls:

asp:RadioButtonList asp:CheckBoxList asp:DropDownList asp:Listbox

Page 30: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

30

Other Data Binding Controls

SortedList object It combines the features of both the ArrayList object and

the Hashtable object. XML Files

We can bind a XML files to get data. Example of XML Data Binding

The Repeater It is used to display a repeated list of items that are bound

to the control.

May be bound to a database table, an XML file, or another list of items example of Repeater

The DataList Same as Repeater, except it adds a table around the data

items by default. DataList DataList <Alternate>

Page 31: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

31

ASP.NET Database connection

To work with databases we need ADO .NET, which is a part of the .NET Framework and it

is used to handle data access.

What is ADO .NET? part of the .NET Framework consists of a set of classes to handle data access is entirely based on XML unlike ADO, has no Recordset object

Example of :Database connection - Repeater control

Page 32: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

32

Helpful Hints

Most of my work are from http://www.w3schools.com/ http://www.asp.net/Tutorials/quickstart.aspx http://www.microsoft.com/net and Beginning ASP.NET 1.0 with Visual Basic.NET

published by wrox Programmer to Programmer ISBN 1-861007-33-7

Also to download this slides you can check at http://fall2003.cs.mnsu.edu/shresb2/aspPresentation.ppt

Page 33: 1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used

33

Thank you

Open for questions or concerns