0% found this document useful (0 votes)
8 views14 pages

LM - Chapter - 2 Intro. To Web-Based Technologies

The document provides an introduction to web-based technologies, focusing on HTTP, HTML, XML, and ASP.NET. It outlines the structure and methods of HTTP, the differences between HTML and XML, and the advantages of using ASP.NET for web application development, including features like state management and event-driven programming. Additionally, it covers the page life cycle in ASP.NET, types of files and directory structure, and fundamental object-oriented programming concepts within the .NET framework.

Uploaded by

bought meat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
8 views14 pages

LM - Chapter - 2 Intro. To Web-Based Technologies

The document provides an introduction to web-based technologies, focusing on HTTP, HTML, XML, and ASP.NET. It outlines the structure and methods of HTTP, the differences between HTML and XML, and the advantages of using ASP.NET for web application development, including features like state management and event-driven programming. Additionally, it covers the page life cycle in ASP.NET, types of files and directory structure, and fundamental object-oriented programming concepts within the .NET framework.

Uploaded by

bought meat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
i . [ Bi Introduction to Web Based Technologies 2.1 HTTP, HTML, XML, ASP BITE ests and information between server and the protocol to transfer hypertext req! browser, There ‘are various methods available with HTTP such as Get, Post, Put, Delete, Trace, Head, Options, Connect and so on. 0 HTTP structure Initial line Zero or more header lines A blank tine Optional message body 0 Initial request line Method / request URL / HTTP / ver E.g. GET/ virtual dir /[Link] / HTTP / 1.0 2 Response Line HTTP / ver code Description Ex. HTTP/ 1.0200 0K E.g. HTTP / 1.0404 Not found message | ! Here first digit in status code identifies the general category of response. Message body | is not available in get method. Data is the part of URL. 4 0 Status code ¥_ 1xx indicates an information message only ~ 2xx indicates success of some kind Y 3xx indicates redirection of the client to another URL ” _ 4xx indicates an error on the clients port Y 5xx indicates an error occur on server port HIML : é Itis presentation oriented markup language, It can be use to develop the layout of the page. It contains pre-defined tags for building the layout. nee XML Itis content oriented markup language, Itis used to describe semantic of data: Wecan user-defined iagsto store the data Itisalsouse totansferthe nan ra nak ren ASPNET re Itis Server side seripting language. The HTML and scripting code (VBScript, Iscript) are ssiten ina single file It is access via HTTP requests, Scripting code is interpreted on server side ) What can we do? y_ Itis quick and easy to create simple web application, y Weare able to generate dynamic web content. We can use client side scripting for validation, yt supports access to COM components such as database to extend functionality. 0 Example <% if (request form(“bl”)<>”")then [Link] “ Hello,the time is” & Now() end if %> ; Here Now() returns date and time of server. We can use java script for client side script. Itis simple procedural programming language. It can access to COM components such as ActiveX Data Object (ADO), File system object, and Custom components. It is script based (i.c. there is no need for compilation); we just need to edit, save, and run. 5 Short comings of ASP ¥ Mix layout (HTML) and logic (scripting code) “interpreting ASP code leads to performance loss Uses scripting languages that are not strongly typed © MS Jscript o MS VB scripting edition ¥ Browser compatibility Y No real state management 0 No state sharing access to web forms © State is lost when IIS fails ¥ Updates files only when server is down 2.2 [Link] [Link] is the Web Based technology developed by Microsoft and incorporated in Visual [Link]. With the help of ASPNET, we can develop web application as well as the web service. It support full fledge Object-Oriented programming languages. Before the execution of the application, itis compiled and then after whenever the page is requested it is served from this compiled code. So, there is performance enhancement with ASPNET. Introduction to Web Based Technologies then also we can retrieve our critical data 0 [Link] core concepts % Itsupports separation of presentation layout and business logic, ¥ Ituses the services provided by .NET framework. ¥ [Link] compiled only first time when a page is requested. ¥ Itsuprorts State management, ‘s language i.e. Cross language integration, We can update files, while server is running < done only for first request of application a Features ¥ Web forms ¥ Web services ¥ Built on NET framework_ ¥ Simple programming model ¥ Maintain page state % Multi browser support ¥ Xcopy deployment ¥ Xml configuration ¥ Complete object model ¥ Session management ¥_ Caching ! ” Debugging v Extensibility ¥ Separation of code and Ul Y Security vy ASPX and ASP side by side ~. Simplified form validation Y Cookieless sessions 2.3 Compiled Code a ae —13 : Ithas the facility that itcan detect client browser and according to it generate HTML. State Management and cookies data can be stored on Third party server, so ifour server crashes To develop the application in [Link]. we can make use of programming FITML pages are targeted to the capabilities of requesting browser ¥ InASPNET, for anew Tequest it creates object of page class, so compilation is lu order to serve the request given by the user, ASP'NET must first compile the code. We can rite the [Link] code in any of the language supported by NET framework. When we compile the code, itis translated info MSIL which is language — independent. Then this MSILis converted into Machine — Specific: instructions. 14 ASPNET 0 Benefits of Compiled Code ¥ Stability: When the code is compiled, it is checked for syntax error, type safety, ete so that many errors can be eliminated from the later stage. Performance: The execution of the compiled code is faster then the scripts such as cript which is much similar to the machine code. Compiled code is difficult to read. So no one can convert compiled code into source code, Interoperability: We are able to use assemblies written in different languages as MSIL supports any NET language. 2.3.1 Inline code (In-Page Code) Traditional ASP developers were using this approach. In this approach scripting code working for generating desired output was intermixed with HTML code to create user friendly pages as well as specific functionality was added to the web pages. But often, the combined intermixed code become ambiguous for maintaining the readability of large web pages. For ASP Net web pages, you can also use inline code but it becomes difticult to maintain the server side events of all the server controls on a single page. The code is written in tag in the .aspx page that contains the HTML and controls. 2.3.2 CodeBehind = [Link] framework provides a facility to maintain the code for large pages by designing separate files for HTML code and the code file in which we can write the code in VB or C# language. So this approach of developing the web pages is called Code Behind. It separates the design layout and the coding part. ‘The HTML and controls are in the .aspx file and the code is in [Link] or [Link] file. At the time of compilation both the files are combined and one class is generated which is then used to serve the user request. Hence, we can say that the web pagesare in the form of class. So when the page is requested the instance of the page is served. 2.4 Event Driven Programming There are two programming approaches: Linear and Event Driven, Any identifiable occurrence that has significance for system hardware or software is called the Event. So we can say that, Event is the action or the occurrence that is detected by the Program. User-generated events include keystrokes and mouse clicks, among a wide variety of other possibilities. The programming approach, which response to the event or handle the event is called a Driven Programming, Windows operating system is the Event Driven Program 0 [Link] Event Model Traditional ASP uses the Linear Model, It means that the code on the page is executed from top to bottom, whenever the page is loaded, {Introduction to Web Based Technolog But ASPNET uses Event Driven Model. User can add controls on the page according to the need we ean decide which event will respond. Hote eaci’e handler is the separate method, [Link] works as follows: 1, When the page is executed for the first time, it creates the page and control obj. Along With, the initialization code is executed and the page is rendered. e 2, After the page is served to the user, any event can be triggered due to the performed by the user. 3 3. If the Button Click () event generates the postback of the form. [Link] te: the page by re-creating it 4. Then it raises the appropriate event which has triggered the postback, S. At last the modified page is rendered to HTML and served to the client, 2.5 Page Life Cyele When the user request the page, [Link] checks that the class for the page is avail not. If itis present, then it creates the instance of the page class and gives response, the class is not present then it goes under the page life cycle. When the request comes the ASPX page is given for parsing to the ASPX engine, from that parsed page and the Code behind class, a combined page classis generated a is compiled. At last the instance of the class is created and rendered for the user. In: Web Forms are in the form of Page Class. : (Fig: (.a) Page Life Cycle] 2.5.1 Phases of Page Life Cycle . 0 Page Request’ Aswe have seen in above diagram, the page Tequest occurs before i Suirs I checks thatthe page needs tobe parsed and compiled oro. ‘ fart In this phase, several properties such as Re: are set. Along with, it checks that the t are Posted Back to: ise requestoraot. 3 re ASPNET 0 Page Initialization During this phase, the controls are available on the page and its ID Property is set then themes are [Link] the request is the postback request, the postback data are not loaded and the values of the controls are not restored from the ViewState Load Now in this phase, the request is the postback request, the postback data is loaded and the values of the controls are not restored from the ViewState. Validation In this phase, if the validation controls are present on the page then its Validate method is called, which in turn set the IsValid property of the controls and page. Postback event handling SS eeetres Ifthe event handlers of the PostBack are need to be called, then they are called. during this phase. Rendering’ Prior to this phase, the View State for page and controls are savéd. During rendering phase Render() method of the controls and page is called which gives the output to the QuiputStream ofthe Response property. Unload The page comes in this phase, when there is a need to dispose the page as it might not be further needed. Request and Response propertiesof the page is also unloaded. / 2.5.2 Page Events i 0 o Page Prelnit() This event is used for the following purpose: Y Check the IsPostBack property to determine whether the page is being processed first time. Create or re-create dynamic controls, Seta master page dynamically. Set the Theme propesty dynamically. Y Read or set profile property values. Page _Init() 5 i It is executed after the Prelnit() event. It is use to retrieve or initialize control properties. Page_Preload() ek S Prior to this event, the ViewState data and PostBack data are restored to the éoatrols. This eventis used if we want to do some task before load event isexecuted. Page Load(Q) 5 x Itealls the Load event of the page as well as each control on the page. This event is use {0 set the properties of the controls and it can also be used to establish database connections”. “y qana ana 3 Control_events . : é ‘They are useful to handle the eventsof the controls. [Link] of the Button, : Introduction t9 Web Based Technotogies. i riisategenetas fy 0 Page_PreRender() n {tis executed for each control on the page, Itis used to make final changes to the page 3 and itscontrols Page Unload() Itis executed for each control and then for the page. So we can say that itis useful for final cleanup such as closing the connection. closing files, completing log etc 2.6 Types of Files and Directory Structure in [Link] - fynes of Files “ [Bite Type —[Deserip scrip { aspx [Link] web page that contain controls and busine: as ‘Web user control file that define cust adiied to the web page. asx [Link] (Global Application Class) file that contains Es | application level events. oe ata ASMX Web service file that contains methods which can be invoke Ny other application, Configuration file that contains XML elements for application ! [ics vb Source code file that contain the business logic behind the page. } csproj, Project Tile for Vistal Studio web application. | vbproj disco ‘An XML Discovery file use to locate web service, } ! ail ‘A Compiled Library or assembly file. I -masier 1 | A master page which can be used to define the layout of other i web pages. db, Database files. : sesources, | A resource file that contains information about the resources _1esx_ such as images, text etc for the application. ! sitemap | XML sitemap file that defines the logical structure of the web application. t “skin A theme file that contains the settings for the controls to define t L consistent formatting. } [sin A solution fit { [Table Types of files} | [Fig (2.b) Directory Structure of web application in VS2008] aaa [Link] Directory Description ] ‘App_Browsers It contains .Browser (browser definition) file that [Link] use to determine the browsers and its _| capabilities. | | | j ‘App_code Itcontains source code files, which can be compiled for application. ‘App_Data It contains data files such as mdb, mdf, XML etc App_GlobaiResources It contains .recources, .resx (resource files) that are compiled into assemblies and used with giobal scope. ‘App_Localftesources Tr contains resource files that are associated with specific page, master page or user control. App_Themes It contains skin files. ‘App_WebReferences It contains the files which is useful when working with web service.E.g. wsdl, disco ete. Bin Tt contains compiled assemblies (dll). [Table: 2 Types of Directory] 2.7 Object Oriented Concepts Object-oriented programming (OOP) is a programming approach that uses “objects” -data structures consisting of data fields and methods - and their interactions to design applications and computer programs. 2.7.1 Class The class is a template through which we can create an object. In .NET, it contains fields, properties, methodsi,e. procedure and functions, and events. Syntax [ ] [ Access Modifier ] { Shadows] [ MustInherit| NotInheritable ] Class name [Implements interfacename ] [statements ] End Class Here access modifiers are Public, Private, Protected, Friend. and Protected Friend. [Link] Fields They are the variables in the class and they can be read or set directly. Public Class Class] Public Fieldi As Integer End Class [Link] Properties Properties are retrieved and set like fields but are implemented using Property Get Property Set procedures which provide more control on how values: Private PropertyValue As String Public Property Prop!() As String ‘are set or retumed. Introduction to Web Based Technolo ges — — $$ _$ < nl Get Return PropertyValue End Ger Ser(ByVal Value As String) PropertyValue = Value Bnd Ser End Property [Link] Methods 4 lethods represent’ the object's built-in procedures. For example, a Class marmed Employee may have methods named CalculateSelary and CaleulateLeave, We can define methods by adding procedures, Sub routines or functions to the class. Example: Public Class Employee Public Sub CalculateSalary() Write("--—-") End Sub Public Sub CalculateLeaveQ) Write ("sm--—-==") End Sub End Class [Link] Events Events allow objects to perform actions whenever a specific occurrence takes place. For example when we click a button, a click event oceurs and we can handle that event aneventhandler. 2.7.2 Object They are the basic runtime entities. They are the variables of the class, It is said to b instance of the class, Syntax. [ }[{Access Modifier | Static })[ Shared }[ Shadows ][ ReadOnly ] Dim { WithEvents Jame [ Sounds) ]{As( New ] ype] cienense a 2.73 Constructor | They ae the special procedures that are invoked automatically for object Public Sub New(ByVal newValue As Intege) oe coma 2 End Sub 2.1.4 Destructor i ‘We know how to ereate constructor, but what abo destructor; it is executed: when an object is destroyed. We can place code ot ‘clean up, ahora ASPNET closing files, in a destructor. In [Link], you can use the Finalize method for this sucpose. The Finalize method is called automatically when the NET runtime determines at the object is no longer needed. pom Th this Sele are creating an object of a class named Class}, and adding a method that beeps when the object is destroyed. Class Form! : inherits Spstem. Windows. Forms. Form Dim Object! As New Class! () Public Class Class! Protected Overrides Sub Finalize() Beepd) Encapsulation process of uniting data members and methods in a single unit is called Encapsulation. In other words, to combine data and function into a single logical unit is known as encapsulation. When using Data Encapsulation, data isnot accessed directly; it is only accessible through the functions present inside the class. Data Encapsulation enables the important concept of data hiding. Protecting data from access by unauthorized function (extemal function) is called data hiding, 2.7.6 Inheritance Itis the process by which object of one class acquire the properties, i.e. data/ attributes of object, of another class. That means inheritance is the process of forming a new class from an existing class or base class. \ ‘The base class is also known as parent class or super class, the new class créatad from base class is called derived class. Derived class is also known as a child’class or sith class. Inheritance helps in reducing the overall code size of the program, which is an ‘important Concept in object-oriented programming. This is important because it supports hierarchical classification. In object oriénted programming the concepts of inheritance provide the idea of reusability. This means that wecan: add additional features to an: existing class without modifying it. This is possible by deriving a new class from the existing one. The new class has the combine features of both the classes. ‘Todinherit the class Inherits Keyword is used with derived class. eee. Introduction to Web Based Technologies os Example: Public Class Person ‘Members of Person class End Class Public Class Employee Inherits Person ‘Members of Employee class End Class 2.7.7 Abstraction Itisa mechanism of representing essential features without including background details. without presenting the details. When the classes use the concept of data abstraction. they are also known as Abstract DataTypes (ADT). [Link] Abstract Class MustInherit keyword is used to declare 2 class that cannot be instantiated and can be used only as a base class, also called an Abstract Base Class(ABC). 2.7.8 Interface : Interfaces can act as specifications for class members; when you implement an interface, you also must implemeni all the specified members. ff class wants to use the interface, it needs to use Implements keyword. Example: Public Interface person Sub SetName(ByVal PersonName As String) Function GetName() As String End Interface 2 Public Class employee a e eras Implements person ones ron ee Dim Name As String 3 = ‘Sub SetName(ByVal PersonName As String} Implements person SetWame Name = PersonName iene ‘ sees End Sub ‘ ik a - APNE Q Multiple Inheritance : : [Link] does not support Multiple Inheritance, where we inherit from multiple base classes at the same time. Butit allows us to implement multiple interfaces. 2.7.9 Polymorphism Itis the Greek word, poly means many and morphism means forms i.e. one name many forms, The ability of functions and operators to act in different ways on different data type is called polymorphism. ; To use one function name for many different purposes is known as function overloading. So. Overloading is one type of Polymorphism. It allows an object to have different meanings, depending on its context. Polymorphism allows routines to use variables of different types whenever required. To implement function overloading, Overloads keyword is used. Example: Overloads Function Add(ByVal al As Integer, [Link] Integer) As Integer res=al +a2 Return res End Function 2 Overloads Function Add(ByVal al As Integer, ByVal a? As Integer, ByVal a3. As Integer) As Integer res=al +a2+a3 Returnres End Function There are two ways to implement polymorphism: 1. Inheritance Based Polymorphism 2. Interface Based Polymorphism 2.7.10 Method Overriding The process in which subclass provide a specifi Overridable: Allows property or method ina class to be overs s Overrides: Overidesan Overdablepropeny ormethod ee lotOverridable: Prevents a property or method from bai i ublicmethodsareNotOverridable by default, 9 “nS OVeTiAden. Note that MustOverride: Requires that a derived class i ride: override the MustOverride methods. ‘must be declared in Mustlaheritclasses ie Introduction 10 Web Based Technologies. 2.7.1) Partial Classes essing Its anew type oF fuReA P: ail class also tow i san sate re ‘ fe nt i jal keyword is used to implementit. : here is the interface named IPartialClass whiich cont PartialClass is the partial class which is splitted it jalClass interface. ‘Now to use this class, on Button c proutinesare invoked. The code isas follows: Por example, t Routines. My! implements Parti itis created and sul [Link] Imports System Interface [PartiaiClass % Sub overloads PrintEmployeeName(By Val sName As String) ‘Sub overloads PrintEmployeeName() End Interface Partial Class MyPartialClass 3 Private sName As String = "Nikisha Jariwala" End Class [Link] Imports System Partial Public Class MyPartialClass Implements [PartialClass a Public Sub PrintEmployeeName(string s) Response. Write(s) End Sua [Link] Jmports System 4 Partial Public Class MyPartialClass Public Sub PrintEmployeeName() Response. Write(sName) End Sub ‘ Write the following code in the click event of a button va rc Det sie the click event of a uh Button! Click(ByVal sender As Obj : a PCI oa ae WyPartaiCleng es lass, PrintEmployeeName("Stri arti ( pagent loyeeName() - elles i ee af ge | | | 24 [Link] 0 Advantages V_ This type of splitting the class file is particularly useful, if a single class contains thousands lines of code with different functionalities across different methods. V Productivity of the project team is increased since a single class file is split across the team members and implementet{as partial classes. _/ It helps in the isolation of the business logic of an application from its user inter V- Itfacilitates easier debugging. v They allow programmers on your team to work on different parts of a class without needing to share the same physical file. ace. NAWAYRH 28, oi Explain structure of HTTP and Status code. What is ASP? Explain its limitations. Explain [Link] with its features. What is Compiled code? Differentiate between In—line code and Code Behind. What is Event Driven Programming? Explain it with respect to ASPNET. | Write a short note on Page Life Cycle. Also explain its different phases and Events ~ performed during the life cycle. List out types of files and directories supported by [Link]. What is OOP? Explain its Basic Concepts. en 10, What is Page Subclassing? Explain it with an example.

You might also like

<