Tải bản đầy đủ (.pdf) (63 trang)

Lecture E-Commerce - Chapter 22: ASP NET (part i)

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (456.53 KB, 63 trang )

CSC 330 E-Commerce
Teacher

Ahmed Mumtaz Mustehsan
GM-IT CIIT Islamabad

Virtual Campus, CIIT
COMSATS Institute of Information Technology

T2-Lecture-1


ASP.NET
Part - I
For Lecture Material/Slides Thanks to: www.w3schools.com


Introduction


Introduction
 ASP.NET

is a development framework for building web
pages and web sites with HTML, CSS, JavaScript and
server scripting.
 ASP.NET supports three different development models:
◦Web Pages,
◦Web Forms.
◦MVC (Model View Controller),


T2-Lecture-11

Ahmed Mumtaz Mustehsan

www.w3schools.com

1-4


Web Pages: Single Pages Model
 Simplest ASP.NET

model.
 Similar to PHP and classic ASP.
 Built-in templates and helpers for database, video,
graphics, social media and more.

T2-Lecture-11

Ahmed Mumtaz Mustehsan

www.w3schools.com

1-5


MVC: Model View Controller
 MVC

separates web applications into 3 different

components:
◦Models for data
◦Views for display
◦Controllers for input

T2-Lecture-11

Ahmed Mumtaz Mustehsan

www.w3schools.com

1-6


Web Forms: Event Driven Model
 The

traditional ASP.NET event driven development
model:
Web pages with added server controls, server events,
and server code.

T2-Lecture-11

Ahmed Mumtaz Mustehsan

www.w3schools.com

1-7



Classic ASP
Classic ASP - Active Server Pages
Active Server Pages (ASP), also known as Classic
ASP, was introduced in 1998 as Microsoft's first server
side scripting engine.
ASP is a technology that enables scripts in web pages
to be executed by an Internet server.
ASP pages have the file extension .asp, and are
normally written in VBScript.

T2-Lecture-11

Ahmed Mumtaz Mustehsan

www.w3schools.com

1-8


ASP.NET
 ASP.NET

is a new ASP generation. It is not compatible
with Classic ASP, but ASP.NET may include Classic
ASP.
 ASP.NET pages are compiled, which makes them
faster than Classic ASP.
 ASP.NET has better language support, a large set of
user controls, XML-based components, and integrated

user authentication.
 ASP.NET pages have the extension .aspx, and are
normally written in VB (Visual Basic) or C# (C sharp).

T2-Lecture-11

Ahmed Mumtaz Mustehsan

www.w3schools.com

1-9


ASP.NET
 User

controls in ASP.NET can be written in different
languages, including C++ and Java.
 When a browser requests an ASP.NET file, the
ASP.NET engine reads the file, compiles and executes
the scripts in the file, and returns the result to the
browser as plain HTML.

T2-Lecture-11

Ahmed Mumtaz Mustehsan

www.w3schools.com

110



ASP.NET Razor
 Razor

is a new and simple markup syntax for
embedding server code into ASP.NET web pages,
much like Classic ASP.
 Razor has the power of traditional ASP.NET, but is
easier to use and easier to learn.

T2-Lecture-11

Ahmed Mumtaz Mustehsan

www.w3schools.com

111


ASP.NET Programming Languages
ASP Programming Languages that we will discuss:
Visual Basic (VB.NET)
C# (Pronounced C sharp)

T2-Lecture-11

Ahmed Mumtaz Mustehsan

www.w3schools.com


112


ASP.NET Development Options (methods)
 ASP.NET

is a development framework for building web
pages and web sites with HTML, CSS, JavaScript and
server scripting.
 ASP.NET supports three different Server Development
Technologies / Platforms:
1. Web Pages (with Razor syntax)
2. MVC (Model View Controller)
3. Web Forms

T2-Lecture-11

Ahmed Mumtaz Mustehsan

www.w3schools.com

113


ASP.NET Development Tools
 ASP.NET

supports the following development tools:
1. WebMatrix

2. Visual Web Developer
3. Visual Studio

 Note:

To learn ASP.NET MVC, we will Build an Internet
Application using Visual Web developer

T2-Lecture-11

Ahmed Mumtaz Mustehsan

www.w3schools.com

114


ASP.NET File Extensions
 Classic ASP

files have the file extension .asp
 ASP.NET files have the file extension .aspx
 ASP.NET files with Razor C# syntax have the file
extension .cshtml
 ASP.NET files with Razor VB syntax have the file
extension .vbhtml

T2-Lecture-11

Ahmed Mumtaz Mustehsan


www.w3schools.com

115


ASP.NET
Development Tools
Razor


Synopsis
 Razor

Intro
 Razor Syntax
 Razor C# Variables
 Razor C# Loops
 Razor C# Logic
 Razor VB variables, operator different from C#
 Razor VB Logic (Select statement)

T2-Lecture-14

Ahmed Mumtaz Mustehsan

www.w3schools.com

117



Razor Intro


ASP.NET Razor - Markup
 Razor

is not a programming language. It's a server side
markup language.
 Razor is a markup syntax that lets you embed serverbased code (Visual Basic and C#) into web pages.
 Server-based code can create dynamic web content on
the fly, while a web page is written to the browser.
 When a web page is called, the server executes the
server-based code inside the page before it returns the
page to the browser.
 By running on the server, the code can perform complex
tasks, like accessing databases.
 Razor is based on ASP.NET, and designed for creating
web applications.
 It has the power of traditional ASP.NET markup, but it is
1easier toAhmed
use,
and easierwww.w3schools.com
to learn.
T2-Lecture-14
Mumtaz Mustehsan
19


Razor intro

Razor uses a syntax very similar to PHP and Classic ASP.
Razor:
<ul>
@for (int i = 0; i < 10; i++) {
<li>@i</li>
}
</ul>
PHP:
<ul>
for ($i = 0; $i < 10; $i++) {
echo("<li>$i</li>");
}
?>
</ul>


T2-Lecture-14

Ahmed Mumtaz Mustehsan

www.w3schools.com

120


Razor intro
Web Forms (and Classic ASP):
<ul>
<% for (int i = 0; i < 10; i++) { %>

<li><% =i %></li>
<% } %>
</ul>

T2-Lecture-14

Ahmed Mumtaz Mustehsan

www.w3schools.com

121


Razor Helpers
ASP.NET helpers are components that can be accessed by
single lines of Razor code.
 You can build your own helpers using Razor syntax, or use
built-in ASP.NET helpers.
 Below is a short description of some useful Razor helpers:
◦ Web Grid
◦ Web Graphics
◦ Google Analytics
◦ Facebook Integration
◦ Twitter Integration
◦ Sending Email
◦ Validation


T2-Lecture-14


Ahmed Mumtaz Mustehsan

www.w3schools.com

122


Razor Programming Languages
 Razor

supports both C# (C sharp) and VB (Visual
Basic).

T2-Lecture-14

Ahmed Mumtaz Mustehsan

www.w3schools.com

123


Razor Syntax


Main Razor Syntax Rules for C#
 Razor

code blocks are enclosed in @{ ... }
 Inline expressions (variables / functions) start with @

 Code statements end with semicolon ( ; )
 Variables are declared with the var keyword
 Strings are enclosed with quotation marks
 C# code is case sensitive
 C# files have the extension .cshtml

T2-Lecture-11

Ahmed Mumtaz Mustehsan

www.w3schools.com

125


×