This action might not be possible to undo. Are you sure you want to continue?
• Some references:
• • • • Beginning ASP.NET using VB.NET; Wrox; 2002 chpt 2. Kalata, K, Introduction to ASP.NET – 2002, chpt 1. Esposito, D. Programming Microsoft ASP.NET, chpt 1. Morrison, M. and Morrison, J. Database driven web sites (2nd edn). Chpt 6. • VS.NET on line documentation + Quickstart tutorials
• What is ASP.NET and how is different from ASP
– ASP: server side technology for creating dynamic web pages using scripting languages eg vb script. – ASP.NET: server side technology for creating dynamic web pages using Fully Fledged programming languages supported by .NET – VB.NET: our chosen language for writing ASP.NET pages
What is .NET?
A Microsoft strategy and new technology for delivering software services to the desktop and to the web Components include:
– MS Intermediate Language; all code is complied into a more abstract,
trimmed version before execution. All .NET languages are compiled to MSIL – the common language of .NET The CLR- common language runtime; responsible for executing MSIL code; interfaces to Windows and IIS A rich set of libraries (Framework Class Libraries) available to all .NET languages The .NET languages such as C#, VB.NET etc that conform to CLR ASP.NET is how the Framework is exposed to the web, using IIS to manage simple pages of code so that they can be complied into full .NET programs. These generate HTML for the browser.
• • •
Built on open protocols (XML, SOAP) Future for development of MS & non-MS based systems. Also heading towards the “Internet Operating System”
Common Language Runtime Type System
Compilers use the runtime type system to produce type compatible components Components
Common Type System
Robust And Secure
Native code compilation
MSIL No interpreter Install-time or run-time IL to native compilation
Code correctness and type-safety
IL can be verified to guarantee type-safety No unsafe casts, no uninitialized variables, no out-of-bounds array indexing
Policy grants permissions based on evidence (signatures, origin)
Script Native Code IL Common Language Runtime Standard JIT Compiler Native Code ...NET Execution Model VB VC ..
which is Int32 • The IL that is created is the same for all languages • The assembly is the compiled .NET data type.Common Language Runtime • Lightweight Just-in-time compiler: – MSIL to Native machine language.NET or an int in C# are converted to the same .NET program • The assembly contains the IL along with additional information called metadata • Metadata contains information about the assembly • Use the IL Disassembler (ildasm. Can be ported to numerous platforms • The compiled code is transformed into an intermediate language called the Microsoft Intermediate Language (MSIL or IL) • An integer in Visual Basic .exe) to view the IL within an assembly .
Framework Overview VB C++ C# JScript … Common Language Specification Visual Studio.NET Web Forms (ASP.NET) Win Forms Data and XML Base Class Library Common Language Runtime .
WinForms Controls Drawing ASP..Web Web Services Web Forms System.NET Application Services Windows Application Services System Base Framework ADO.NET IO XML Net SQL Security Threading ServiceProcess Common Language Runtime Type System Metadata Execution .NET Framework Architecture System.
WebControl .Control.Control.NET Server Controls: System.Web.NET: System.UI.Namespace • The base class libraries are organized into logical groupings of code called namespaces • A namespace is a hierarchical way to identify resources in .Web namespace – WebForms: System.Web. and all objects inherit from it – ASP.UI namespace – HTML Server Controls: System.NET • The System object is at the top of the namespace hierarchy.Web.UI.HTMLControl – ASP.
NET namespace <%@ Import NamespaceName %> • Below is a sample of how you would import the ASP.NET adds references to your projects’ commonly used namespaces by default • You can import the namespaces into your page using the @Import directive • The following is the syntax for importing a .NET Page class <%@ Imports System.Page %> .UI.Importing Namespaces • Visual Studio .Web.
Collections System.aspx page is requested System.UI.string Definitions and classes for creating various collections File reading & writing operations Support browser/server communication System.IO System.Web.UI Creates the Page object whenever an .Some ASP.web Classes and definitions to create controls server controls .NET namespaces System System.Web.Web Defines fundamental data types eg system.
NET types and represents them in a form for the web (such as HTML) • Class browser (over 9000 classes.NET provides a means of exposing the .au/quickstart/aspp lus/samples/classbrowser/vb/classbrowser.edu.NET Framework and its functionality to the WWW • Contains a number of pre-built types that take input from .NET – class browser • ASP.aspx . lists the namespaces): http://interdev.ASP.csse.monash.
NET • Visual Studio .asmx .NET • The latest version of ASP is known as ASP.NET Web applications • There are two main types of Web resources created with ASP.NET applications – WebForms are ASP.NET Web pages that contain publicly exposed code so that other applications can interact with them – Web Services are identified with the file extension .NET is a developer application used to create ASP.ASP.NET pages within an ASP.NET application – Web Services are ASP.
and the controls Creates the user interface. or presentation layer Instructs the browser how to format the Web page Is created using a combination of HTML controls.WebForms • The ASP. content.NET controls . Mobile Controls.NET WebForm is separated into two logical areas: – The HTML template – A collection of code behind the WebForm • The HTML template – – – – Contains the design layout. and ASP. HTML Server controls.
except they are processed by the server • Add runat = "server" to the HTML control to transform it into an HTML Server control • HTML control: <input type="text"> • HTML Server control: <input type="text" runat="server"/> <input type=”radio” runat=”server” value=”Yes”/> Yes • Server-side programs can interact with the control before it is rendered as a plain HTML control and sent to the browser .Server Controls • HTML Server controls are similar to the HTML controls.
NET Controls • ASP.NET Form Controls Data Validation Controls User Controls Mobile Controls • ASP." /> .NET Server controls are organized as: – – – – ASP.ASP.NET button: <asp:Button id="ShowBtn" runat="server" Text="Show the message.NET controls are usually identified with the prefix asp: followed by the name of the control • ASP.NET form controls will create the HTML code • ASP.
NET form controls can interact with clientside events such as when the user clicks on a button – When the event occurs. ASP.Text = "Product 2" .NET can trigger a script to run on the server • ASP.NET form controls also have different properties than their HTML server control counterparts – HTML Server label control • Message1.HTML Server Vs ASP.InnerHTML = "Product 1" – ASP server label control • Message2.NET Server. Controls • ASP.
you can create a user control that displays the a navigation bar • You can use this control on the home page.asmx . headers. and footers • User controls replace the functionality of ASP server-side include pages • They are identified with the file extension . menus. they are often used for creating self-contained code.User Controls • User controls are external files that can be included within another WebForm • User controls allow you to reuse code across multiple files • For example.
Server Controls within Visual Studio .NET .NET most of the ASP.NET • In Visual Studio .NET Server controls are located on the Web Forms tab in the toolbox Server controls with Visual Studio.
vb) • C# use .cs) .aspx.cs (mypage.vb (mypage.NET. the application becomes easier to maintain • Only Server controls can interact with the code behind the page – Written in any ASP. Perl.aspx.NET use .NET compatible language such as Visual Basic . or Java – Filename is the same as the WebForm filename – Add a file extension that identifies the language • Visual Basic . C#.The Code Behind • Server programs are written in a separate file known as the code behind the page • By separating the programming logic and presentation layer.
vb" Inherits=“MyFirstApp.Code Behind file • The location of the code behind the page is determined via a property that is set on the first line in the page using the @Page directive <%@ Page Language="vb" Codebehind="WebForm1.WebForm1"%> • The @Page directive allows you to set the default properties for the entire page such as the default language • The CodeBehind property identifies the path and filename of the code behind file • The Inherits property indicates that the code behind the page inherits the page class • This page class contains the compiled code for this page .
NET compiles the code behind the page into an executable file and places the file in the bin directory . and properties that belong to that class • In Visual Studio .NET the process of compiling a class is called building – When you build the application. you compile the code into an executable file – Visual Studio .Compiling the Page Class • The compiled code behind the page is the class definition for the page – A class is a named logical grouping of code – The class definition contains the functions. methods.
and properties that can be accessed within the code behind the page • The first time a page is requested by a client. a series of page events occurs • The first page event is the Page_Init event which initializes the page control hierarchy • The Page_Load event loads any server controls into memory and occurs every time the page is executed .Page Class Events • The Page Class consists of a variety of methods. functions.
Page class events • Page_init • Page_load • Server_Controls • Page_prerender • Page_Unload .
Web Services • Web Services also provide a means to expose .NET functionality on the web but Web Services expose functionality via XML and SOAP (cf: function calls over the web) .
asmx – A public registry known as UDDI contains registered public Web Services. Third party Web Services are available at http://www.com . you could: – Post a link – Scrape a Web site (use a program to view a Web site and capture the source code) – Provide a Web Service to their catalog application Web Services • Web Services are used to create business-tobusiness applications – Web Services allow you to expose part or all of your programs over the Internet.• If your business partner is Course Technology and you want to query that company’s product catalog from your Web site. The Web Service source file has the extension .xmethods.
• The page object generates html that is sent back to IIS and then the browser.How ASP. .NET module (aspnet_isapi.NET works • When . • ASP.dll) to handle them.aspx extension and to use the ASP. IIS is configured to look for files with the . • NOTE: only .NET is installed.aspx file and arranges it in a predefined class definition and generates an asp.aspx files are parsed (if it is pure html don‟t save it as an aspx file as it will slow down the server.NET parses the .net page object.
NET code Example</title> </head> <body> Line1: First HTML Line<br /> Line2: Second HTML Line<br /> Line3: Third HTML Line<br /> </body> </html> • Note this has no asp code so better to use . </script> • Message..NET code declarations ……….ASP.NET samples • Page directives: <%@ page language = “VB” debug="true" trace="true“ %> • <script language = “VB” runat=“server”> VB.aspx <html> <head> <title>Inserting ASP.html extension .
Write ("Third ASP.NET Line<br />") Response.• Message2.Write ("Second ASP.aspx <script language="VB" runat="server"> Sub Page_Load() Response.Write ("First ASP.NET code Example</TITLE> </head> <body> Line1: First HTML Line<br /> Line2: Second HTML Line<br /> Line3: Third HTML Line<br /> </body> </html> .NET Line<br />") Response.NET Line<br />") End Sub </script> <html> <head> <title>Inserting ASP.
aspx html> <head><title>Inserting ASP.• Message3.Write ("Second ASP.Write ("First ASP.NET code Example</title></head> <body> Line1: First HTML Line<br /> Line2: Second HTML Line<br /> Line3: Third HTML Line<br /> <script language="VB" runat="server"> Sub Page_Load() Response.NET Line<br />") End Sub </script> </body> </html> .NET Line<br />") Response.Write ("Third ASP.NET Line<br />") Response.
Write ("Second ASP.Render or inline code block – interweave1. .aspx <html> <head> <title>Interweaving ASP.NET Line<br />") %> </body> </html> NOT RECOMMENDED.NET code and HTML Example</title> </head> <body> Line1: First HTML Line<br /> <% Response.NET Line<br />") %> Line3: Third HTML Line<br /> <% Response.Write ("Third ASP.NET Line<br />") %> Line2: Second HTML Line<br /> <% Response.Write ("First ASP.
Interweave2.NET code Example</TITLE> </head> <body> First HTML Line<br/> <asp:label id=Message runat="server"/> <br /> Second HTML Line<br/> </body> </html> .aspx A Server control script language="VB" runat="server"> Sub Page_Load() Message.Text="The ASP.NET line" End Sub </script> <html> <head> <title>Inserting ASP.
.start Stores links to all project files VS.NET IDE configuration info for the proj.vbproj Event handler commands visible to all web forms in a project Define application resources such as text strings.vb Project. Asp.asax.sln Project.Web application project files AssemblyInfo.resx Global.dll Global.net code for application events eg session.asax Global.asax. images.vb Info about the compiled project file stored in /bin and named project. Configuration and build settings for project files.suo Project. Can change without recompiling project.
dll Bin\project.aspx file.webinfo Project.vbproj.aspx.Html Resources in corresponding web form Code written for the form (code behind) Bin\project. Project.vsdisco URL to project web server Enables search for web services Styles.vb Project style sheet Project and folder configuration information Web form .pdb Compiled project output file (assembly) Debugging information used by developer .resx Webform.aspx Webform.config Webform.css Web.Web application project files cont.aspx.
compile the class into an assembly.vb .displays hello world ' Created 06/01/2002 Imports System Public Module Hello Sub Main() Dim s1 As String = "1 .Hello World" Console.Viewing the Assembly • Create a simple class.WriteLine(s1) End Sub End Module ' Run this at the command line ' vbc hello.vb . then view the class using the IL Disassembler • Open Notepad and type the code shown: ' hello.
Using the ILDASM to View the Assembly and Classes Using the ILDASM to view the assembly and classes .
net templates Intro11shows validation controls Intro13 shows code behind pages • Server directives eg trace and debug – trace .Examples • quickstart – webforms – – – – – – – Intro4 shows VIEWSTATE Intro6 shows a click event Intro7 shows a usercontrol with a calander Intro8 shows a db connection Intro9 & 10 show asp.
.csse.Net is webmatrix • Some samples on another machine – http://interdev. You must copy this subdirectory when moving to another machine or home.NET will create a subdirectory in c:/inetpub/wwwroot for your project. • You create your web projects with Visual Studio..au/cse2030/ Interdev is not accessible outside the Monash network.The lab environment.Net.monash. VS. • URL – http://localhost:1900/MyfirstApp/homepage.edu.aspx • Alternative to VS. • Each machine is set up to be an IIS server – http://localhost:1900/….
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue listening from where you left off, or restart the preview.