Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 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

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

3 Common Language Runtime Type System Compilers use the runtime type system to produce type compatible components Components Compilers Common Type System C#VBC++ Runtime Environment

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

5 .NET Execution Model VBVC...Script MSIL Native Code Common Language Runtime Standard JIT Compiler

6 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

7 Framework Overview Base Class Library Common Language Specification Common Language Runtime Data and XML VBC++C# Visual Studio.NET Web Forms (ASP.NET) JScript… Win Forms

8 . NET Framework Architecture Common Language Runtime MetadataType SystemExecution System Base Framework IONetSecurityServiceProcess ADO.NETXMLSQLThreading System.Web Web ServicesWeb Forms ASP.NET Application Services System.WinForms ControlsDrawing Windows Application Services

9 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/(ve32xyu1a1303kb4ji53 xxqi)/default.aspx http://academic1.bellevue.edu/showtables/default.aspx

10 ASP.NET High developer productivity Great performance and reliability Fast deployment.

11 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

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

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

14 Rich Class Framework Application features that used to be hard to implement, or required a 3 rd -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!

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

16 Rich output caching Web-Farm Session State Microsoft.NET Outperforms J2EE Performance and Scalability cont.

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

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

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

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

21 ASP.NET samples Page directives: VB.NET code declarations ……….. test.html or test.aspx Code Example Line1: First HTML Line Line2: Second HTML Line Line3: Third HTML Line Note this has no asp code so better to use.html extension

22 test2.aspx Sub Page_Load() Response.Write ("First ASP.NET Line ") Response.Write ("Second ASP.NET Line ") Response.Write ("Third ASP.NET Line ") End Sub Inserting ASP.NET code Example Line1: First HTML Line Line2: Second HTML Line Line3: Third HTML Line

23 test3.aspx html> Inserting ASP.NET code Example Line1: First HTML Line Line2: Second HTML Line Line3: Third HTML Line Sub Page_Load() Response.Write ("First ASP.NET Line ") Response.Write ("Second ASP.NET Line ") Response.Write ("Third ASP.NET Line ") End Sub

24 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.)

25 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

26 Server side controls HTMLControls –System.Web.UI.HtmlControls namespace –Can be directly mapped to HTML tags –Used for backward compatibility with ASP eg 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 Programmatic reference of a control is by the unique id attribute eg id=“txtname”

27 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

28 Example Sub Page_Load() if Request.Form("list1") <> "" then Message.text = "You have selected " + Request.Form("list1") end if End Sub Drop Down List Example Which city do you wish to look at hotels for? Madrid Oslo Lisbon

29 Output

30 Output 2

31 Output 2 source code in HTML Drop Down List Example You have selected Lisbon Which city do you wish to look at hotels for? Madrid Oslo Lisbon

32 Output 2 source code cont. All output from server to browser is HTML New attributes added to form tag – –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 –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.

33 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

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

35

36

37

38

39 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

40 Example Sub GreetMe(s As Object, e As EventArgs) label1.Text = "Hello " & txtName.Value & _ ". I see your occupation is " & lstTitle.Value End Sub Name: Profession: Software Engineer Software Tester Program Manager

41 Output

42 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

43 ASP.NET Vs PHP FeaturePHPASP.NET HTMLYes CSSYes ‘php Templates’YesUserControls ServerControls (buttons,grids etc) NoYes JavascriptYesYes + Validation controls Database ConnYes Cookies & Sessions Yes VIEWSTATENoYes POSTBACKNoYes

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


Download ppt "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."

Similar presentations


Ads by Google