20

ASP.NET Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

Embed Size (px)

DESCRIPTION

ASP.NET is a server-side technology for developing web applications based on the.NET Framework.

Citation preview

Page 1: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework
Page 2: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

ASP .NET – Active Server Pages

Page 3: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

ASP.NET is a server-side technology for developingweb applications based onthe .NET Framework.

Page 4: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

Terminology Reminder:web application – same as

dynamic website.

Page 5: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

• ASP.NET has been created in response to such technologies as CGI, PHP, etc., that allow creating dynamic webpages

• ASP.NET allows use of multiple languages (C#, VB, others)

• ASP.NET pages are compiled, not interpreted

Page 6: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

Essentially, ASP.NET requires using:• Windows, although .NET

Framework has been ported to other operating systems, as well

• Microsoft’s Internet Information Services (IIS) server (although a small server named Cassini exists for hobbyists)

Page 7: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

• Microsoft SQL Server is also required, if one needs a webpage to interact with a database (required in any serious web development)

Page 8: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

Technical details:• web pages are text files with .aspx extension• web files should be placed in the directory C:\Inetpub\wwwroot• files cannot be opened locally from Explorer, only via the web server• default.aspx is a default page

Page 9: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework
Page 10: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

Structure of an ASP.NET page:• directives• code declaration blocks• code render blocks• ASP.NET server controls• server side comments• literal text and HTML tags.

Page 11: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

Role of the directives:• control how the page is compiled• allow importing classes• specify page caching in a browser• assist in debugging.Directives start with <%@ and end with %> Example of a directive:<%@ Page Language=“C#” %>

Page 12: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

Code declaration blocks help separate the application logic from HTML contents. The application logic defines variables, subroutines, functions, etc.

Page 13: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

Example of a code declaration block:

<script runat=”server”> void mySub() { // Code placed here }</script>

Page 14: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

Code render blocks define inline code and inline expressions.Inline code render blocks execute one or more statements and are placed inside HTML code delimited by <% … %>Inline expression render blocks display values of variables/methods.

Page 15: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

Example of a code render block:<% string Title=”text”; %>

Example of inline expression render block:<%= Title %>

Page 16: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

ASP.NET server controls • are central to every ASP.NET page• represent page’s dynamic elements• usually must reside within a <form runat=“server”> tag• fall into 3 categories: ASP.NET controls, HTML controls, and web user controls.

Page 17: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

Server side comments allow including text, which will not be processed by ASP.NET.They are included in special type of brackets:<%-- comments go here --%>

Page 18: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

Literal text and HTML tags provide the structure for presenting dynamic data, give a page the right format, which the browser can understand.

Page 19: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

Sample code<%@ Page Language=”C#” %><!DOCTYPE html PUBLIC ”-//W3C//DTD XHTML 1.0 Strict//EN” ”http://www.w3.org/TR/xtml1/DTD/html1-strict.dtd”><HTML> <HEAD> <TITLE>Sample Page</TITLE> <SCRIPT runat=”server”> void Page_Load() { messageLabel.Text = ”Hello World”; } </SCRIPT> </HEAD> <BODY> <FORM runat=”server”> <P> <ASP:Label id=”messageLabel” runat=”server” /> <P> <%-- Declare title as string and set it --%> <% string Title=”From code render block”; %> <%= Tiltle %> </FORM> </BODY></HTML>

Page 20: ASP.NET  Active Server Pages ASP.NET is a server-side technology for developing web applications based on the.NET Framework

Summary

All of the dynamic portions of the web pages in ASP.NET are usually contained within code render blocks or controls located inside a tag:<form runat=”server”>