Introduction to asp net
This presentation is the property of its rightful owner.
Sponsored Links
1 / 44

Introduction to ASP.NET PowerPoint PPT Presentation


  • 68 Views
  • Uploaded on
  • Presentation posted in: General

Introduction to ASP.NET. What is .NET 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.

Download Presentation

Introduction to ASP.NET

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Introduction to asp net

Introduction to ASP.NET

  • What is .NET

  • 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

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. Such as Linux, Unix…


Common language runtime type system

Common Language Runtime Type System

Compilers use the runtime type system to produce type compatiblecomponents

Components

C#

VB

C++

Compilers

Runtime Environment

Common Type System


Robust and secure

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 non-initialized variables, no out-of-bounds array indexing

  • Evidence-based security

    • Policy grants permissions based on evidence (signatures, origin)


Net execution model

.NET Execution Model

VB

VC

...

Script

NativeCode

MSIL

Common Language Runtime

Standard JITCompiler

NativeCode


Common language runtime

Common Language Runtime

  • Lightweight Just-in-time compiler:

    • MSIL(Intermediate language) to Native machine language

    • Can be ported to numerous platforms

    • Free/Net BSD UNIX port has been announced

    • “MONO” Open source movement


Framework overview

Framework Overview

VB

C++

C#

JScript

Visual Studio.NET

Common Language Specification

Web Forms

(ASP.NET)

Win Forms

Data and XML

Base Class Library

Common Language Runtime


Net framework architecture

.NET Framework Architecture

System.WinForms

System.Web

Controls

Drawing

Web Services

Web Forms

Windows Application Services

ASP.NET Application Services

System Base Framework

ADO.NET

XML

SQL

Threading

IO

Net

Security

ServiceProcess

Common Language Runtime

Type System

Metadata

Execution


Asp net

ASP.NET

  • ASP.NET provides a means of exposing the .NET Framework and its functionality to the WWW

  • Contains a number of pre-built types that take input from .NET types and represents them in a form for the web (such as HTML)

  • Example:

    http://academic1.bellevue.edu/asp.net/examples/lesson11/(ve32xyu1a1303kb4ji53xxqi)/default.aspx

    http://academic1.bellevue.edu/showtables/default.aspx


Asp net1

ASP.NET

  • High developer productivity

  • Great performance and reliability

  • Fast deployment.


Easy programming model

Easy Programming Model

  • ASP.NET makes building real world Web applications dramatically easier.  ASP.NET server controls enable an HTML-like style of declarative programming that let you build great pages with far less code than with classic ASP.  Displaying data, validating user input, and uploading files are all amazingly easy.  Best of all, ASP.NET pages work in all browsers -- including Netscape, Opera, AOL, and Internet Explorer


Flexible language options

Flexible Language Options

  • ASP.NET lets you leverage your current programming language skills.  Unlike classic ASP, which supports only interpreted VBScript and JScript, ASP.NET now supports more than 25 .NET languages (including built-in support for VB.NET, C#, and JScript.NET -- no tool required), giving you unprecendented flexibility in your choice of language.


Great tool support

Great Tool Support

  • You can harness the full power of ASP.NET using any text editor -- even Notepad!  But Visual Studio .NET adds the productivity of Visual Basic-style development to the Web.  Now you can visually design ASP.NET Web Forms using familiar drag-drop-doubleclick techniques, and enjoy full-fledged code support including statement completion and color-coding.  


Rich class framework

Rich Class Framework

  • Application features that used to be hard to implement, or required a 3rd-party component, can now be added in just a few lines of code using the .NET Framework.  The .NET Framework offers over 4500 classes that encapsulate rich functionality like XML, data access, file upload, regular expressions, image generation, performance monitoring and logging, transactions, message queuing, SMTP mail, and much more!


Performance and scalability

Performance and Scalability

  • ASP.NET is much faster than classic ASP, while preserving the "just hit save" update model of ASP.  However, no explicit compile step is required!  ASP.NET will automatically detect any changes, dynamically compile the files if needed, and store the compiled results to reuse for subsequent requests.


Introduction to asp net

Performance and Scalabilitycont.

  • Rich output caching

  • Web-Farm Session State

  • Microsoft .NET Outperforms J2EE


Reliability

Reliability

  • Memory Leak, DeadLock and Crash Protection.  ASP.NET automatically detects and recovers from errors like deadlocks and memory leaks to ensure your application is always available to your users. 


Easy deployment

Easy Deployment

  • "No touch" application deployment. .NET dramatically simplifies installation of your application.

  • Dynamic update of running application.  ASP.NET now lets you update compiled components without restarting the server.

  • Easy Migration Path.  You don't have to migrate your existing applications to start using ASP.NET. 


Web services

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)


How asp net works

How ASP.NET works

  • When .NET is installed, IIS is configured to look for files with the .aspx extension and to use the ASP.NET module (aspnet_isapi.dll) to handle them.

  • ASP.NET parses the .aspx file and arranges it in a predefined class definition and generates an asp.net page object.

  • The page object generates html that is sent back to IIS and then the browser.

  • NOTE: only .aspx files are parsed (if it is pure html don’t save it as an aspx file as it will slow down the server.


Asp net samples

ASP.NET samples

  • Page directives: <%@ page language = “VB” debug="true" trace="true“ %>

  • <script language = “VB” runat=“server”> VB.NET code declarations ……….. </script>

  • test.html or test.aspx

    <html>

    <head> <title>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 .html extension


Introduction to asp net

  • test2.aspx

    <script language="VB" runat="server">

    Sub Page_Load()

    Response.Write ("First ASP.NET Line<br />")

    Response.Write ("Second ASP.NET Line<br />")

    Response.Write ("Third ASP.NET Line<br />")

    End Sub

    </script>

    <html> <head> <title>Inserting ASP.NET code Example</TITLE> </head>

    <body>

    Line1: First HTML Line<br />

    Line2: Second HTML Line<br />

    Line3: Third HTML Line<br />

    </body>

    </html>


Introduction to asp net

  • test3.aspx

    html>

    <head><title>Inserting 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.Write ("First ASP.NET Line<br />")

    Response.Write ("Second ASP.NET Line<br />")

    Response.Write ("Third ASP.NET Line<br />")

    End Sub

    </script>

    </body>

    </html>


Asp net form

ASP.NET Form

  • An ASP.NET form is a HTML form plus asp.net code in the form of server controls.

  • ASP.NET form has extra functionality to maintain form data or state (_VIEWSTATE) eg text in a text box

    • Hidden variable to store ‘coded’ version of the form

  • ASP.NET server controls duplicate the functionality of many HTML elements.

    • Take the form of an html-like tag, marking the point in the page where the server needs to generate corresponding true HTML elements. (produces server side object that can be manipulated at any part of the code.)


Web forms

Web Forms

  • Server side controls

  • Generate output suitable for the browser

  • Preserves state across page refreshes (Viewstate)

  • Raise server side events

  • Used as the base to build richer controls

  • ASP.Net includes a range of useful classes and namespaces

    • Namespace is like a class library eg. System.Web.UI.HtmlControls


Server side controls

Server side controls

  • HTMLControls

    • System.Web.UI.HtmlControls namespace

    • Can be directly mapped to HTML tags

    • Used for backward compatibility with ASP

      eg <input type=“text” runat=“server” id=“txtname” value=“mytext” >

  • Web Controls

    • System.Web.UI.WebControls namespace

    • Form based event model eg buttonclick

    • Offer a richer set of controls

      • implement a number of common properties (properties through class browser)

      • data binding

      • automatic browser detection

        <asp:textbox id=“txtname” runat=“server” text=“mytext”>

  • Programmatic reference of a control is by the unique id attribute eg id=“txtname”


How do server controls work

How do server controls work?

  • Declared with the runat=“server” attribute

  • when the aspx page is executed

    • creates Action and Method attributes of the form

    • adds unique Id and Name attributes to controls

    • adds Value attribute to controls

    • adds a hidden control (_VIEWSTATE) to the form to save form state information


Example

Example

<script runat="server" language="vb">

Sub Page_Load()

if Request.Form("list1") <> "" then

Message.text = "You have selected " + Request.Form("list1")

end if

End Sub

</script>

<html> <head> <title>Drop Down List Example</title> </head>

<body>

<asp:label id="message" runat="server"/> <br />

<form runat="server"> <!– notice no action or method attributes -->

Which city do you wish to look at hotels for?<br /><br />

<asp:dropdownlist id="list1" runat="server">

<asp:listitem>Madrid</asp:listitem>

<asp:listitem>Oslo</asp:listitem>

<asp:listitem>Lisbon</asp:listitem>

</asp:dropdownlist> <br /><br /><br /><br />

<input type="Submit">

</form> </body> </html>


Output

Output


Output 2

Output 2


Output 2 source code in html

Output 2 source code in HTML

<html>

<head>

<title>Drop Down List Example</title>

</head>

<body>

<span id="message">You have selected Lisbon</span>

<br />

<form name="_ctl0" method="post" action="listpage.aspx" id="_ctl0">

<input type="hidden" name="__VIEWSTATE" value="dDwtMTMyNTU5Mzc0Njt0PDtsPGk8MT47PjtsPHQ8cDxwPGw8VGV4dDs+O2w8WW91IGhhdmUgc2VsZWN0ZWQgTGlzYm9uOz4+Oz47Oz47Pj47PtM3XxNyv4v6En+WgxP4D5/iJj1M" />

Which city do you wish to look at hotels for?<br /><br />

<select name="list1" id="list1">

<option value="Madrid">Madrid</option>

<option value="Oslo">Oslo</option>

<option selected="selected" value="Lisbon">Lisbon</option>

</select> <br /><br /><br /><br />

<input type="Submit">

</form> </body> </html>


Output 2 source code cont

Output 2 source code cont.

  • All output from server to browser is HTML

  • New attributes added to form tag

    • <form name="_ctl0" method="post" action="listpage.aspx" id="_ctl0">

    • Post is the asp.net default method

    • Action attribute points to the same page (listpage.aspx)

    • A hidden control stores the state of the page

      <input type="hidden" name="__VIEWSTATE" value="dDwtMTMyNTU5Mzc0Njt0PDtsPGk8MT47PjtsPHQ8cDxwPGw8VGV4dDs+O2w8WW91IGhhdmUgc2VsZWN0ZWQgTGlzYm9uOz4+Oz47Oz47Pj47PtM3XxNyv4v6En+WgxP4D5/iJj1M" />

    • Used by asp.net to keep track of all server control settings from one page refresh to another; otherwise listbox would revert to static default setting every time page is loaded. Very useful for data validation.


Web controls

Web controls

  • There are five types of controls

    • Intrinsic Controls eg asp:list, asp:button etc

    • List Controls eg asp:datagrid, asp:datarepeater

    • Rich Controls eg asp:calander

    • Validation Controls eg asp:rangeValidator

    • Custom Controls – user defined

  • They support properties, methods and events


Web control events

Web control events

  • Each web control has a number of events (onClick…etc)

  • There are events associated with server events (Page_load..etc)

  • Each event results in a reload of the page via a postback

  • A web control is asociated to an event by setting its attributes - the name of the function which implements the event handler.


Page event life circle

Page event life circle

  • In ASP.NET a structured set of events occurs every time a page is viewed. The order is:

    • Page_init (done once; useful for variable initialisation)

    • Page_load (can be used to load data into controls from server DB) see POSTBACK

    • Change events eg textbox1_changed; by default only click events submit form to the server; change events are queued till then. (Some controls have an AUTOPOSTBACK property which will force a post)

    • Click event eg button1_click

    • Page_Unload (last event before page is discarded eg user going to another page; useful for closing files, db’s etc


Example1

Example

<%@ Page Language="vb" %>

<HTML> <body>

<SCRIPT language="VB" runat="Server">

Sub GreetMe(s As Object, e As EventArgs)

label1.Text = "Hello " & txtName.Value & _

". I see your occupation is " & lstTitle.Value

End Sub

</SCRIPT>

<FORM runat="server">

Name: <INPUT type="text" id="txtName" runat="server">

<p>Profession: <SELECT id="lstTitle" runat="server">

<OPTION> Software Engineer </OPTION>

<OPTION> Software Tester </OPTION>

<OPTION> Program Manager </OPTION>

</SELECT>

<p><INPUT type="Submit" Value="Save" onServerClick="GreetMe" runat="server">

<p><asp:label id="label1" runat="server"/>

</FORM> </body> </html>


Output1

Output


Configuration and deployment

Configuration and Deployment

  • Configuration details are in a text file called web.config that is structured in XML format. This is in the site’s root folder

  • All files that a Web application needs are in folder under the site’s root folder and DLL’s are in the /bin folder (don’t have to register in the Registry; only need to copy)

    /wwwroot

    /webapplication1 - aspx, web.config

    /bin - dll’s

    /webapplication2 - aspx, web.config

    /bin - dll’s


Asp net vs php

ASP.NET Vs PHP


Asp net summary

ASP.NET Summary

Writing dynamic, high-performance Web applications has never been easier by using ASP.NET


  • Login