Introduction to asp net
1 / 44

Introduction to ASP.NET - PowerPoint PPT Presentation

  • Uploaded on

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.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Introduction to ASP.NET' - quasim

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






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







Common Language Runtime

Standard JITCompiler


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





Visual Studio.NET

Common Language Specification

Web Forms


Win Forms

Data and XML

Base Class Library

Common Language Runtime

Net framework architecture
.NET Framework Architecture





Web Services

Web Forms

Windows Application Services

ASP.NET Application Services

System Base Framework









Common Language Runtime

Type System



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:

Asp net1

  • 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.

Performance and Scalabilitycont.

  • Rich output caching

  • Web-Farm Session State

  • Microsoft .NET Outperforms J2EE


  • 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 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


    <head> <title>Code Example</title> </head>


    Line1: First HTML Line<br />

    Line2: Second HTML Line<br />

    Line3: Third HTML Line<br />



    • Note this has no asp code so better to use .html extension

  • 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


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


    Line1: First HTML Line<br />

    Line2: Second HTML Line<br />

    Line3: Third HTML Line<br />



  • test3.aspx


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


    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




Asp net form

  • An ASP.NET form is a HTML form plus 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


<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


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


<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:dropdownlist> <br /><br /><br /><br />

<input type="Submit">

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

Output 2 source code in html
Output 2 source code in HTML



<title>Drop Down List Example</title>



<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 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 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


<%@ 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


<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>


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

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

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

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)


    /webapplication1 - aspx, web.config

    /bin - dll’s

    /webapplication2 - aspx, web.config

    /bin - dll’s

Asp net summary
ASP.NET Summary

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