Pertemuan ke 13 PENGENALAN ASP NET v v

  • Slides: 34
Download presentation
Pertemuan ke 13 PENGENALAN ASP. NET § v v Tentang ASP Pengenalan ASP HTML

Pertemuan ke 13 PENGENALAN ASP. NET § v v Tentang ASP Pengenalan ASP HTML Intermediate Formatting with Tables, Frames Collecting information from the user using Forms Pemrograman Web/TI/ AK 045216/2 sks 1

Apa itu ASP ? • Microsoft® Active Server Pages (ASP) merupakan server-side scripting yang

Apa itu ASP ? • Microsoft® Active Server Pages (ASP) merupakan server-side scripting yang digunakan untuk membuat situs yang dinamis dan aplikasi web yang interaktif. • Sesuai prinsip server-side scripting, ASP juga merupakan halaman HTML yang diisikan script-script yang diproses oleh web server sebelum dikirim ke web browser. • ASP dapat dikombinasikan dengan : – Extensible Markup Language (XML) – Component Object Model (COM) – Hyper Text Markup Language (HTML) Pemrograman Web/TI/ AK 045216/2 sks 2

Perbandingan PHP dan ASP Dengan persamaan sebagai server-side scripting, ASP dapat dibandingkan dengan PHP

Perbandingan PHP dan ASP Dengan persamaan sebagai server-side scripting, ASP dapat dibandingkan dengan PHP dalam beberapa hal berikut ini (secara umum) : ASP PHP Sistem Operasi Microsoft Windows Unix, Linux Web Server Personal Web Server (PWS) Internet Information Server (IIS) Apache Web Server Database Microsoft Access Microsoft SQL Server My. SQL, Oracle, dll Basic sintaks Visual Basic (VB) C / C++ Ekstensi file . asp . php Pemrograman Web/TI/ AK 045216/2 sks Postgres, 3

Contoh script ASP - 1 • VBScript adalah bahasa scripting standar untuk membuat halaman

Contoh script ASP - 1 • VBScript adalah bahasa scripting standar untuk membuat halaman ASP. Pada contoh-contoh script berikut digunakan VBScript: • Contoh 1 : – Langkah pembuatan : • Masukkan text ‘Hello World’ pada variabel First. Var • Buat tag awal HTML • Gunakan <%First. Var%> untuk menampilkan isi variabel First. Var • Akhiri tag HTML – Script lengkap : • • <%@ Language=VBScript %> <html> <head> <title>Example 1</title> </head> <body> <% First. Var = "Hello world!" %> <%=First. Var%> </body> </html> Pemrograman Web/TI/ AK 045216/2 sks 4

Contoh script ASP - 2 • Contoh 2 : <%@ Language=VBScript %> <html> <head>

Contoh script ASP - 2 • Contoh 2 : <%@ Language=VBScript %> <html> <head> <title>Example 2</title> </head> <body> <% First. Var = "Hello world!" %> <%FOR i=1 TO 10%> <%=First. Var%> <%NEXT%> </body> </html> • Contoh 3 : <%@ Language=VBScript %> <html> <head> <title>Example 4</title> </head> <body> <%IF Hour(time)>18 OR Hour(time)<4 THEN%> Good Night Everyone. <%ELSE%> Good Morning Everyone. <%END IF%> </body> </html> Pemrograman Web/TI/ AK 045216/2 sks 5

Perkembangan ASP • Saat ASP ver 3. 0 diluncurkan, programmer menemukan banyak hal yang

Perkembangan ASP • Saat ASP ver 3. 0 diluncurkan, programmer menemukan banyak hal yang mempermudah proses pembuatan program. Ini dikarenakan ASP telah diperkaya berbagai fungsi. • Namun programmer masih menemukan masalah umum dalam penggunaan ASP, yaitu ASP bersifat ‘code-oriented’. Yang artinya segala hal yang ingin ‘dibuat’ haruslah ditulis dengan kode-kode script. • Microsoft mengeluarkan framework. NET pada Juli, 2000. • Dengan adanya framework ini, programmer dapat membuat program lebih ringkas dan cepat. • Hal ini dikarenakan penggunaan framework yang dapat mengurangi jumlah script yang dibuat oleh progammer. Pemrograman Web/TI/ AK 045216/2 sks 6

Perkembangan ASP • Beberapa keunggulan framework. NET : – Menggunakan model programming deklaratif –

Perkembangan ASP • Beberapa keunggulan framework. NET : – Menggunakan model programming deklaratif – Server kontrol hirarki dengan events. – Class library yang cukup banyak. – Support terhadap development tools, dari yang sederhana (notepad) hingga Visual Studio. NET • ASP. NET mulai diperkenalkan kepada programmer sebagai pengganti penggunaan ASP klasik. • ASP. NET versi 1. 0 dan 1. 1 diluncurkan untuk pertama kali dan berharap saran dari pengguna untuk penyempurnaan ASP. NET versi berikutnya. Pemrograman Web/TI/ AK 045216/2 sks 7

Generasi Pertama. NET Client Logic Biz Logic Browsers Servers Data, Hosts OS Services Penggunaan

Generasi Pertama. NET Client Logic Biz Logic Browsers Servers Data, Hosts OS Services Penggunaan HTML oleh programmer untuk membuat user interface aplikasi web. Microsoft menyediakan COM, IIS, Internet Explorer Aplikasi web berjalan sesuai prinsip server-client. Pihak industri membuat perangkat pembantu seperti database SQL Server™. Pemrograman Web/TI/ AK 045216/2 sks 8

Generasi Kedua. NET Rich Client Logic Browsers Biz Tier Logic OS Services COM+ Services

Generasi Kedua. NET Rich Client Logic Browsers Biz Tier Logic OS Services COM+ Services ditingkatkan. Internet Explorer menyediakan DHTML untuk interaktif web Servers Data, Hosts “Stateful” “Stateless” & “Geo-Scalable Pemisahan data dan bisnis proses mempercepat proses pembacaan aplikasi Pemrograman Web/TI/ AK 045216/2 sks 9

Platform. NET Visual Studio®. NET Your Application and Web Service A p p l

Platform. NET Visual Studio®. NET Your Application and Web Service A p p l i c a ti o n s Usi n g Y o u r S ervi ce E n d -U s e r C l i e n ts Operatio ns O r c h e s tr a ti o n. NE T F ramew o r k W i n d o w s® CE , 2000, X P , . NE T Internet Protocols rd 3 SOAP “blue book” Pemrograman Web/TI/ AK 045216/2 sks HTTP, SMTP, XML Your Internal Services. NET Enterprise Servers. NET Foundation Services Party Web Services 10

Framework. NET Visual Basic® C++ C# JScript® … ASP. NET: Web Services and Web

Framework. NET Visual Basic® C++ C# JScript® … ASP. NET: Web Services and Web Forms Windows Forms ADO. NET: Data and XML Base Class Library Common Language Runtime Pemrograman Web/TI/ AK 045216/2 sks V i s u a l S tu d i o. N E T Common Language Specification 11

ASP. NET dan Visual Studio®. NET didesain untuk pembuatan web aplikasi • • •

ASP. NET dan Visual Studio®. NET didesain untuk pembuatan web aplikasi • • • Perancangan untuk web aplikasi dan XMLWeb services Drag and drop untuk penggunaan tag HTML Penggunaan bahasa pemrograman yang terintegrasi Pemrograman Web/TI/ AK 045216/2 sks 12

Introduction ASP. NET • • • Membangun class programming dari framework. NET Pengontrolan dan

Introduction ASP. NET • • • Membangun class programming dari framework. NET Pengontrolan dan pembangunan infrastruktur pengembangan web apliksi Contoh web aplikasi : Pemrograman Web/TI/ AK 045216/2 sks 13

ASP Klasik • • • Penggunaan model programming prosedural yang sederhana. Mengakses ke COM

ASP Klasik • • • Penggunaan model programming prosedural yang sederhana. Mengakses ke COM Objects : – ADO – File system object Tanpa proses compile, hanya save (simpan). Mendukung penggunaan berbagai bahasa scripting. Gabungan antara HTML dan kode script. VBscript – leverage Visual Basic skills Kendala : • • • Code readability Coding overhead Post. Back complexity Reuse Performance DLL locking Deployment Sessions Caching Pemrograman Web/TI/ AK 045216/2 sks 14

Arsitektur ASP. NET Compiled Pemrograman Web/TI/ AK 045216/2 sks . ASPX 15

Arsitektur ASP. NET Compiled Pemrograman Web/TI/ AK 045216/2 sks . ASPX 15

Kehandalan ASP. NET • • ASPX, ASP – side by side Simplified programming model

Kehandalan ASP. NET • • ASPX, ASP – side by side Simplified programming model Simplified deployment Better performance Caching Security Powerful controls Simplified browser support • • • Simplified form validation Code behind pages More powerful data access Web services Better session management No DLL locking No DLL registration Simplified configuration Pagelets Pemrograman Web/TI/ AK 045216/2 sks 16

Page Development Separation of Code from Content • Pemisahan kode-kode script terhadap konten sehingga

Page Development Separation of Code from Content • Pemisahan kode-kode script terhadap konten sehingga designer dan programmer dapat bekerja lebih independen ASP Single file ASP. NET Separate files code <tags> Form 1. asp <tags> code Web. Form 1. aspx. vb Pemrograman Web/TI/ AK 045216/2 sks 17

Page Development Parse Dynamic Compilation Request ASPX File ASPX Engine Generate Codebehind class file

Page Development Parse Dynamic Compilation Request ASPX File ASPX Engine Generate Codebehind class file Gen’d Page Class File Instantiate Response Page Class Instantiate, process and render Pemrograman Web/TI/ AK 045216/2 sks 18

Demonstration 1 ASP vs. ASP. NET Data-Driven ASP. NET Comparison Pemrograman Web/TI/ AK 045216/2

Demonstration 1 ASP vs. ASP. NET Data-Driven ASP. NET Comparison Pemrograman Web/TI/ AK 045216/2 sks 19

Server Controls Simplify Common Tasks • • • Simplify common tasks – Forms –

Server Controls Simplify Common Tasks • • • Simplify common tasks – Forms – Tables – Data display – Calendar – Ad rotator Server-side programming model Automatic browser compatibility Less code, less complexity Extensible Pemrograman Web/TI/ AK 045216/2 sks 20

Server Controls HTML and Server Controls <div id="My. Div" runat="server"/> <asp: Text. Box id="txt.

Server Controls HTML and Server Controls <div id="My. Div" runat="server"/> <asp: Text. Box id="txt. User. Name" runat="Server"/> <asp: button type="submit" On. Click="Submit. Btn_Click" runat="server"/> ID – uniquely identifies control Runat – enables server-side processing On. Click – identifies server-side event handler Pemrograman Web/TI/ AK 045216/2 sks 21

Server Controls Forms <script language="C#" runat=server> void Submit. Btn_Click(Object sender, Event. Args e) {

Server Controls Forms <script language="C#" runat=server> void Submit. Btn_Click(Object sender, Event. Args e) { Response. Write (“Hello” + txt. User. Name. Text); } </script> Post. Back – Server-side object automatically populated from client-side controls Pemrograman Web/TI/ AK 045216/2 sks 22

Server Controls Browser Support Targets client on the fly <asp: textbox Fore. Color=“red”/> –

Server Controls Browser Support Targets client on the fly <asp: textbox Fore. Color=“red”/> – Style – Font Validation – Client-side – Server-side Pemrograman Web/TI/ AK 045216/2 sks 23

Demonstration 2 Server Controls Walk-Through Programming Model Syntax Pemrograman Web/TI/ AK 045216/2 sks 24

Demonstration 2 Server Controls Walk-Through Programming Model Syntax Pemrograman Web/TI/ AK 045216/2 sks 24

Server Controls Validation Without code – – – Required field Within range Two fields

Server Controls Validation Without code – – – Required field Within range Two fields equal (password) Regular expressions Validation error messages With code, but simplified – Custom validation Pemrograman Web/TI/ AK 045216/2 sks 25

Demonstration 3 Validation Required Field Validation Summary Pemrograman Web/TI/ AK 045216/2 sks 26

Demonstration 3 Validation Required Field Validation Summary Pemrograman Web/TI/ AK 045216/2 sks 26

Data Controls Bind to many data sources – Collections • Array • Hash. Table

Data Controls Bind to many data sources – Collections • Array • Hash. Table – ADO. NET • Data. Reader • Data. Set – XML Pemrograman Web/TI/ AK 045216/2 sks 27

Data Controls ADO. NET • • • Connection Command Data. Reader Data. Set Data.

Data Controls ADO. NET • • • Connection Command Data. Reader Data. Set Data. Adapter Data. View Pemrograman Web/TI/ AK 045216/2 sks 28

Data Controls ADO. NET Data. Set Database Authors Connection Authors Data. Adapter Select …

Data Controls ADO. NET Data. Set Database Authors Connection Authors Data. Adapter Select … from Authors Pemrograman Web/TI/ AK 045216/2 sks 29

Data Controls ADO. NET Data. Set Database Authors Connection Publishers Data. Adapter Select …

Data Controls ADO. NET Data. Set Database Authors Connection Publishers Data. Adapter Select … from Publishers Pemrograman Web/TI/ AK 045216/2 sks 30

Data Controls ADO. NET Data. Set Data. Grid Authors Repeater Publishers Data. List Data.

Data Controls ADO. NET Data. Set Data. Grid Authors Repeater Publishers Data. List Data. View Pemrograman Web/TI/ AK 045216/2 sks 31

Data Controls Data. Grid • • Displays data as a table Control over –

Data Controls Data. Grid • • Displays data as a table Control over – Alternate item – Header – Footer – Colors, font, borders, etc. – Paging Updateable Item as row Pemrograman Web/TI/ AK 045216/2 sks 32

Data Controls Repeater • • • List format No default output More control More

Data Controls Repeater • • • List format No default output More control More complexity Item as row Not updateable Pemrograman Web/TI/ AK 045216/2 sks 33

Data Controls Data. List • • • Directional rendering Good for columns Item as

Data Controls Data. List • • • Directional rendering Good for columns Item as cell Alternate item Updateable Pemrograman Web/TI/ AK 045216/2 sks 34