pengenalan aspagungsr.staff.gunadarma.ac.id/downloads/files/71633/... · dikarenakan asp telah...
Post on 17-Nov-2020
8 Views
Preview:
TRANSCRIPT
PENGENALAN ASP.NET
Pemrograman Web/TI/ AK045216/2 sks
Tentang ASP Pengenalan ASP
HTML Intermediate Formatting with Tables, Frames Collecting information from the user using Forms
Apa itu ASP ?
•Microsoft® Active Server Pages (ASP) merupakan server-sidescripting yang digunakan untuk membuat situs yang dinamis danaplikasi web yang interaktif.
•Sesuai prinsip server-side scripting, ASP juga merupakan halamanHTML yang diisikan script-script yang diproses oleh web serversebelum dikirim ke web browser.
•ASP dapat dikombinasikan dengan :
– Extensible Markup Language (XML)– Component Object Model (COM)– Hyper Text Markup Language (HTML)
Pemrograman Web/TI/ AK045216/2 sks
•Microsoft® Active Server Pages (ASP) merupakan server-sidescripting yang digunakan untuk membuat situs yang dinamis danaplikasi web yang interaktif.
•Sesuai prinsip server-side scripting, ASP juga merupakan halamanHTML yang diisikan script-script yang diproses oleh web serversebelum dikirim ke web browser.
•ASP dapat dikombinasikan dengan :
– Extensible Markup Language (XML)– Component Object Model (COM)– Hyper Text Markup Language (HTML)
Perbandingan PHP dan ASP
Dengan persamaan sebagai server-side scripting, ASP dapat dibandingkandengan PHP dalam beberapa hal berikut ini (secara umum) :
ASP PHPSistem Operasi Microsoft Windows Unix, Linux
Web Server Personal Web Server (PWS)Internet Information Server (IIS)
Apache Web Server
Pemrograman Web/TI/ AK045216/2 sks
Web Server Personal Web Server (PWS)Internet Information Server (IIS)
Apache Web Server
Database Microsoft AccessMicrosoft SQL Server
MySQL, Postgres,Oracle, dll
Basic sintaks Visual Basic (VB) C / C++
Ekstensi file .asp .php
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 FirstVar• Buat tag awal HTML• Gunakan <%FirstVar%> untuk menampilkan isi variabel FirstVar• Akhiri tag HTML
– Script lengkap :• <%@ Language=VBScript %>• <html> <head> <title>Example 1</title> </head>• <body>• <% FirstVar = "Hello world!" %>• <%=FirstVar%>• </body>• </html>
Pemrograman Web/TI/ AK045216/2 sks
•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 FirstVar• Buat tag awal HTML• Gunakan <%FirstVar%> untuk menampilkan isi variabel FirstVar• Akhiri tag HTML
– Script lengkap :• <%@ Language=VBScript %>• <html> <head> <title>Example 1</title> </head>• <body>• <% FirstVar = "Hello world!" %>• <%=FirstVar%>• </body>• </html>
Contoh script ASP - 2
•Contoh 2 :<%@ Language=VBScript %><html> <head> <title>Example 2</title> </head><body><% FirstVar = "Hello world!" %><%FOR i=1 TO 10%> <%=FirstVar%><%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 NightEveryone.
<%ELSE%> Good Morning Everyone. <%END IF%>
</body> </html>
Pemrograman Web/TI/ AK045216/2 sks
•Contoh 2 :<%@ Language=VBScript %><html> <head> <title>Example 2</title> </head><body><% FirstVar = "Hello world!" %><%FOR i=1 TO 10%> <%=FirstVar%><%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 NightEveryone.
<%ELSE%> Good Morning Everyone. <%END IF%>
</body> </html>
Perkembangan ASP
• Saat ASP ver 3.0 diluncurkan, programmer menemukan banyakhal yang mempermudah proses pembuatan program. Inidikarenakan ASP telah diperkaya berbagai fungsi.
• Namun programmer masih menemukan masalah umum dalampenggunaan ASP, yaitu ASP bersifat ‘code-oriented’. Yangartinya segala hal yang ingin ‘dibuat’ haruslah ditulis dengankode-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/ AK045216/2 sks
• Saat ASP ver 3.0 diluncurkan, programmer menemukan banyakhal yang mempermudah proses pembuatan program. Inidikarenakan ASP telah diperkaya berbagai fungsi.
• Namun programmer masih menemukan masalah umum dalampenggunaan ASP, yaitu ASP bersifat ‘code-oriented’. Yangartinya segala hal yang ingin ‘dibuat’ haruslah ditulis dengankode-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.
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 sebagaipengganti penggunaan ASP klasik.
• ASP.NET versi 1.0 dan 1.1 diluncurkan untuk pertama kali danberharap saran dari pengguna untuk penyempurnaan ASP.NETversi berikutnya.
Pemrograman Web/TI/ AK045216/2 sks
• 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 sebagaipengganti penggunaan ASP klasik.
• ASP.NET versi 1.0 dan 1.1 diluncurkan untuk pertama kali danberharap saran dari pengguna untuk penyempurnaan ASP.NETversi berikutnya.
OSOSServicesServices
Generasi Pertama .NET
BrowsersBrowsers
ServersServersData, HostsData, Hosts
Client LogicClient Logic
Biz LogicBiz Logic
Pemrograman Web/TI/ AK045216/2 sks
OSOSServicesServices
Microsoft menyediakanCOM, IIS, Internet Explorer
Aplikasi web berjalan sesuai prinsipserver-client. Pihak industri membuatperangkat pembantu seperti databaseSQL Server™.
Penggunaan HTML olehprogrammer untuk membuatuser interface aplikasi web.
“Stateful”“Stateful”“Stateless” &“Stateless” &“Geo“Geo--Scalable”Scalable”
RichRichClient LogicClient Logic
Generasi Kedua .NET
ServersServersData, HostsData, Hosts
OSOSServicesServices
BizBizTier LogicTier Logic
BrowsersBrowsers
Pemrograman Web/TI/ AK045216/2 sks
“Stateless” &“Stateless” &“Geo“Geo--Scalable”Scalable”
OSOSServicesServicesBrowsersBrowsers
Pemisahan data danbisnis prosesmempercepat prosespembacaan aplikasi
COM+ Services ditingkatkan. InternetExplorer menyediakan DHTML untukinteraktif web
Platform .NET
Oper
atio
nsOp
erat
ions
OrchestrationOrchestration .NET Enterprise.NET EnterpriseServersServers
Your InternalYour InternalServicesServicesVisualVisual
StudioStudio®® .NET.NETYour ApplicationYour Applicationand Web Serviceand Web Service
Pemrograman Web/TI/ AK045216/2 sks
Internet ProtocolsInternet ProtocolsSOAP “blue book”SOAP “blue book”HTTP, SMTP, XMLHTTP, SMTP, XML
.NET.NETFrameworkFramework
WindowsWindows®®
CE, 2000, XP, .NETCE, 2000, XP, .NETOp
erat
ions
Oper
atio
ns
ApplicationsApplicationsUsing YourUsing Your
ServiceService
EndEnd--UserUserClientsClients
.NET Enterprise.NET EnterpriseServersServers
.NET Foundation.NET FoundationServicesServices
33rdrd Party Web ServicesParty Web Services
Framework .NET
Common Language SpecificationCommon Language Specification
Visual BasicVisual Basic® C++C++ C#C#Visual Studio .N
ETVisual Studio .N
ET
ASP.NET: Web ServicesASP.NET: Web Servicesand Web Formsand Web Forms
JScriptJScript® ……
WindowsWindowsFormsForms
Pemrograman Web/TI/ AK045216/2 sks
Base Class LibraryBase Class Library
Common Language RuntimeCommon Language Runtime
ADO.NET: Data and XMLADO.NET: Data and XML
Visual Studio .NET
Visual Studio .NET
ASP.NET: Web ServicesASP.NET: Web Servicesand Web Formsand Web Forms
WindowsWindowsFormsForms
ASP.NET dan Visual Studio
• Perancangan untuk webaplikasi dan XMLWebservices
• Drag and drop untukpenggunaan tag HTML
• Penggunaan bahasapemrograman yangterintegrasi
ASP.NET dan Visual StudioASP.NET dan Visual Studio®® .NET didesain untuk.NET didesain untukpembuatan web aplikasipembuatan web aplikasi
Pemrograman Web/TI/ AK045216/2 sks
• Perancangan untuk webaplikasi dan XMLWebservices
• Drag and drop untukpenggunaan tag HTML
• Penggunaan bahasapemrograman yangterintegrasi
Introduction ASP.NET
• Membangun classprogramming dariframework .NET
• Pengontrolan danpembangunaninfrastrukturpengembangan webapliksi
• Contoh web aplikasi :
Pemrograman Web/TI/ AK045216/2 sks
• Membangun classprogramming dariframework .NET
• Pengontrolan danpembangunaninfrastrukturpengembangan webapliksi
• Contoh web aplikasi :
ASP Klasik
• Penggunaan model programmingprosedural yang sederhana.
• Mengakses ke COM Objects :– ADO– File system object
• Tanpa proses compile, hanya save(simpan).
• Mendukung penggunaan berbagaibahasa scripting.
• Gabungan antara HTML dan kode-kode script.
• VBscript – leverage Visual Basicskills
Kendala :• Code readability• Coding overhead• PostBack complexity• Reuse• Performance• DLL locking• Deployment• Sessions• Caching
Pemrograman Web/TI/ AK045216/2 sks
• Penggunaan model programmingprosedural yang sederhana.
• Mengakses ke COM Objects :– ADO– File system object
• Tanpa proses compile, hanya save(simpan).
• Mendukung penggunaan berbagaibahasa scripting.
• Gabungan antara HTML dan kode-kode script.
• VBscript – leverage Visual Basicskills
Kendala :• Code readability• Coding overhead• PostBack complexity• Reuse• Performance• DLL locking• Deployment• Sessions• Caching
Arsitektur ASP.NET
Pemrograman Web/TI/ AK045216/2 sks
.ASPX.ASPXCompiledCompiled .ASPX.ASPXCompiledCompiled
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/ AK045216/2 sks
• 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
Page Development
Separation of Code from Content• Pemisahan kode-kode script terhadap konten sehingga designer
dan programmer dapat bekerja lebih independen
Separate filesSingle fileASPASP ASP.NETASP.NET
Pemrograman Web/TI/ AK045216/2 sks
Form1.aspForm1.asp WebForm1.aspxWebForm1.aspx WebForm1.aspx.vbWebForm1.aspx.vb
<tags> <tags> codecodecodecode
Separate filesSingle file
Page Development
Gen’dPageClassFile
GenerateGenerate
InstantiateInstantiate
ParseParse ASPXASPXEngineEngine
ASPXFile
RequestRequest
CodeCode--behindbehindclassclassfilefile
ASPXFile
DynamicCompilation
Pemrograman Web/TI/ AK045216/2 sks
ResponseResponse
ResponseResponsePagePageClassClass
Instantiate, processInstantiate, processand renderand render
Gen’dPageClassFile
InstantiateInstantiateASPXFile
RequestRequest
RequestRequestASPXFile
Demonstration 1ASP vs. ASP.NET
Data-Driven ASPData-Driven ASP.NET
Comparison
Pemrograman Web/TI/ AK045216/2 sks
Demonstration 1ASP vs. ASP.NET
Data-Driven ASPData-Driven ASP.NET
Comparison
Server ControlsSimplify 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/ AK045216/2 sks
• Simplify common tasks– Forms– Tables– Data display– Calendar– Ad rotator
• Server-side programming model• Automatic browser compatibility• Less code, less complexity• Extensible
Server ControlsHTML and Server Controls
<div id="MyDiv" runat="server"/>
<asp:TextBox id="txtUserName" runat="Server"/>
<asp:button type="submit" OnClick="SubmitBtn_Click"runat="server"/>
ID – uniquely identifies controlRunat – enables server-side processingOnClick – identifies server-side event handler
Pemrograman Web/TI/ AK045216/2 sks
<div id="MyDiv" runat="server"/>
<asp:TextBox id="txtUserName" runat="Server"/>
<asp:button type="submit" OnClick="SubmitBtn_Click"runat="server"/>
ID – uniquely identifies controlRunat – enables server-side processingOnClick – identifies server-side event handler
Server ControlsForms
<script language="C#" runat=server>
void SubmitBtn_Click(Object sender, EventArgs e) {
Response.Write (“Hello” + txtUserName.Text);
}
</script>
PostBack– Server-side object automatically populated from client-side
controls
Pemrograman Web/TI/ AK045216/2 sks
<script language="C#" runat=server>
void SubmitBtn_Click(Object sender, EventArgs e) {
Response.Write (“Hello” + txtUserName.Text);
}
</script>
PostBack– Server-side object automatically populated from client-side
controls
Server ControlsBrowser Support
Targets client on the fly<asp:textbox ForeColor=“red”/>
– Style– Font
Validation
– Client-side– Server-side
Pemrograman Web/TI/ AK045216/2 sks
Targets client on the fly<asp:textbox ForeColor=“red”/>
– Style– Font
Validation
– Client-side– Server-side
Demonstration 2Server Controls Walk-Through
Programming ModelSyntax
Pemrograman Web/TI/ AK045216/2 sks
Demonstration 2Server Controls Walk-Through
Programming ModelSyntax
Server ControlsValidation
Without code
– Required field– Within range– Two fields equal (password)– Regular expressions– Validation error messages
With code, but simplified
– Custom validation
Pemrograman Web/TI/ AK045216/2 sks
Without code
– Required field– Within range– Two fields equal (password)– Regular expressions– Validation error messages
With code, but simplified
– Custom validation
Demonstration 3Validation
Required FieldValidation Summary
Pemrograman Web/TI/ AK045216/2 sks
Demonstration 3Validation
Required FieldValidation Summary
Data Controls
Bind to many data sources– Collections
• Array• HashTable
– ADO.NET• DataReader• DataSet
– XML
Pemrograman Web/TI/ AK045216/2 sks
Bind to many data sources– Collections
• Array• HashTable
– ADO.NET• DataReader• DataSet
– XML
Data ControlsADO.NET
• Connection• Command• DataReader• DataSet• DataAdapter• DataView
Pemrograman Web/TI/ AK045216/2 sks
• Connection• Command• DataReader• DataSet• DataAdapter• DataView
Data ControlsADO.NET
AuthorsAuthorsAuthorsAuthorsConnectionConnection
DatabaseDatabaseDataSetDataSet
AuthorsAuthors
Pemrograman Web/TI/ AK045216/2 sks
AuthorsAuthorsAuthorsAuthorsConnectionConnection
DataAdapterDataAdapterSelect … from AuthorsSelect … from Authors
Data ControlsADO.NET
PublishersPublishersPublishersPublishersConnectionConnection
DatabaseDatabaseDataSetDataSet
AuthorsAuthors
Pemrograman Web/TI/ AK045216/2 sks
PublishersPublishersPublishersPublishersConnectionConnection
DataAdapterDataAdapterSelect … fromSelect … from
PublishersPublishers
PublishersPublishers
Data ControlsADO.NET
DataSetDataSetAuthorsAuthors DataGridDataGrid
RepeaterRepeater
Pemrograman Web/TI/ AK045216/2 sks
PublishersPublishers
DataViewDataView
DataListDataList
RepeaterRepeater
Data ControlsDataGrid
• Displays data as a table• Control over
– Alternate item– Header– Footer– Colors, font, borders, etc.– Paging
• Updateable• Item as row
Pemrograman Web/TI/ AK045216/2 sks
• Displays data as a table• Control over
– Alternate item– Header– Footer– Colors, font, borders, etc.– Paging
• Updateable• Item as row
Data ControlsRepeater
• List format• No default output• More control• More complexity• Item as row• Not updateable
Pemrograman Web/TI/ AK045216/2 sks
• List format• No default output• More control• More complexity• Item as row• Not updateable
Data ControlsDataList
• Directional rendering• Good for columns• Item as cell• Alternate item• Updateable
Pemrograman Web/TI/ AK045216/2 sks
• Directional rendering• Good for columns• Item as cell• Alternate item• Updateable
top related