1
1
1
1
OBJECT ORIENTED PROGRAMMING
• Classes
– Characteristics (Name, Attributes, Methods)
• Objects
– An instance of a class
• Inheritance
– Base Class and Derived Class
• Encapsulation
– Data can be encapsulated such that it is invisible to the “outside world”.
– Data can only be accessed via methods
• Polymorphism
SOFTWARE ARCHITECTURES OVERVIEW
• File Server
– In a file server a computer attached to a network that provides a location
for shared disk access.
• Such as documents, sound files, photographs, movies, images, databases, etc.
– Can be accessed by the workstations that are able to reach the computer that
shares the access through a computer network.
– The term server highlights the role of the machine in the client–server scheme,
where the clients are the workstations using the storage.
– A file server does not perform computational tasks, and does not run programs
on behalf of its clients.
SOFTWARE ARCHITECTURES OVERVIEW
• Two-Tier Architecture
– Client Server architecture (Client Tier, Data
Tier)
– Direct communication
– No intermediate between client and server.
SOFTWARE ARCHITECTURES OVERVIEW
• Three Tier Architecture
– Client layer, Business layer, and Data layer
Client Layer:
▪ Also called as Presentation layer, contains UI part of our application.
Business Layer:
▪ Interface between Client layer and Data Access Layer (Intermediary layer).
▪ Includes business logics (validation of data, calculations, data insertion)
SOFTWARE ARCHITECTURES OVERVIEW
Data Layer:
▪ Actual Database
▪ Methods to connect with database
▪ Perform insert, update, delete, get data
from database based on our input data.
PAGE FRAMEWORK OVERVIEW
Page Life Cycle and Page Events
❖ PreInit
o Check the IsPostBack property
o Create or re-create dynamic controls.
o Set a master page dynamically.
o Set the Theme property dynamically.
PAGE EVENTS (CONT..)
❖ Init
o Raised after all controls have been initialized
o Each control's UniqueID is set and any skin settings have been applied.
o The Init event of individual controls occurs before the Init event of the
page.
o Use this event to read or initialize control properties.
❖ InitComplete
o Raised once all initializations of the page and its controls have been
completed.
o Till now the viewstate values are not yet loaded, we can use this event
to make changes to view state.
PAGE EVENTS (CONT..)
❖ PreLoad
o Raised after the page loads view state for itself and all controls
❖ Load
o The Page object calls the OnLoad method on the Page object, and then
recursively does the same for each child control until the page and all
controls are loaded. The Load event of individual controls occurs after the
Load event of the page.
o This is the first place in the page lifecycle that all values are restored.
o Most code checks the value of IsPostBack to avoid unnecessarily resetting
state.
PAGE EVENTS (CONT..)
o We may also call Validate and check the value of IsValid in this method.
o We can also create dynamic controls in this method.
o Use the OnLoad event method to set properties in controls and establish
database connections.
❖ Control Events
o Calls any events on the page or its controls that caused the PostBack to
occur, such as a Button control's Click event or a TextBox control's
TextChanged event.
PAGE EVENTS (CONT..)
❖ LoadComplete
o Raised at the end of the event-handling stage.
o Use this event for tasks that require that all other controls on the page be
loaded.
❖ PreRender
o Allows final changes to the page or its control.
o This event takes place before saving ViewState.
o After this event, we cannot change any property of a button or change
any viewstate value
o The PreRender event of individual controls occurs after the PreRender
event of the page.
PAGE EVENTS (CONT..)
❖ SaveStateComplete
o Use this event perform tasks that require the view state to be saved, but
that do not make any changes to controls.
❖ Render
o The Render method generates the client-side HTML, Dynamic Hypertext
Markup Language (DHTML), and script that are necessary to properly
display a control at the browser.
❖ Unload
o This event is used for cleanup code.
o This event occurs for each control and then for the page.
DEALING WITH POSTBACKS
o if (Page.IsPostBack == true) {
//Do something
}
❖ CROSS-PAGE POSTING
o Enables you to submit a form (Page1.aspx) and have this form and all the
control values post themselves to another page (Page2.aspx).
PAGE DIRECTIVES
o Page Directives are commands.
o These commands are used by the compiler when the page is compiled.
o Starts with "<%@" and ends with "%>
o Format: <%@[Directive] [Attributes]%>
o Directive examples:
– @Page
– @Master
– @Control
– @Register
– @Import
COMPILATION
COMPILATION (CONT..)
COMPILATION (CONT..)
❖ In-place precompilation
– To precompile your entire ASP.NET application, you must use the
aspnet_compiler.exe tool that comes with ASP.NET.
• C:\Windows\Microsoft.NET\Framework
– You can also get to this tool directly from the Visual Studio 2010
Command Prompt.
– After you get the command prompt, you use the aspnet_compiler.exe tool
to perform an in-place precompilation using the following command:
• aspnet_compiler -p "C:\Inetpub\wwwroot\WROX" -v none
COMPILATION (CONT..)
❖ Precompilation for deployment
– Compile your application down to some DLLs, which can then be deployed to
customers, partners, or elsewhere for your own use.
– This means that your Web site code is completely removed and placed in the DLL
when deployed.
– Before you take these precompilation steps, create a folder in your root drive
called, for example, Compiled. This folder is the one to which you will direct the
compiler output.
• aspnet_compiler -v [Application Name] -p [Physical Location] [Target]
• aspnet_compiler -v /SampleWebsite -p D:\SampleWebsite D:\SampleWebsite\Compiled
– -v is a command for the virtual path of the application,
– –p, which is pointing to the physical path of the application.
COMPILATION (CONT..)
– Note that this compilation process does not compile every type of
Web file.
• HTML files
• XML files
• XSD files
• web.config files
• Text files
BUILD PROVIDERS
– The App_Code is a special folder in the application which will build the items inside it.
– A build provider is a code generator that places the results of the build into memory so that it is
accessible by the runtime
– Build providers are preconfigured for all of the common file types such as .aspx, .ascx, .asmx, and
several others.
– System.Web.Compilation.PageBuildProvider is a default providers used by the ASP.NET to
compile and build .aspx extension pages.
– There are many other providers used by ASP.NET when building the application. Each provider is
registered using an extension and the type.
• <add extension=".aspx" type="System.Web.Compilation.PageBuildProvider" />
• <add extension=".ascx" type="System.Web.Compilation.UserControlBuildProvider" />
• <add extension=".master" type="System.Web.Compilation.MasterPageBuildProvider" />
• <add extension=".asmx" type="System.Web.Compilation.WebServiceBuildProvider" />
GLOBAL.ASAX
– Used by the application to hold application-level events, objects, and variables
– ASP.NET applications can have only a single Global.asax file.
Events
– Application_Start
• Called when the application receives its very first request.
• Assign any application-level variables or state that must be maintained across all users.
– Session_Start
• Fired when an individual user accesses the application for the first time.
• The Application_Start event fires once when the first request comes in, which gets the
application going, but the Session_Start is invoked for each end user who requests
something from the application for the first time.
GLOBAL.ASAX (CONT..)
– Application_BeginRequest
• Triggered before each and every request that comes its way.
• Before request is processed, the Application_BeginRequest is triggered and dealt with
before any processing of the request occurs.
– Application_ AuthenticateRequest
• Triggered for each request and enables you to set up custom authentications for a
request.
– Application_ Error
• Triggered when an error is thrown anywhere in the application by any user of the
application.
• This is an ideal spot to provide application-wide error handling or an event recording the
errors to the server’s event logs
GLOBAL.ASAX (CONT..)
– Session_End
• Code that runs when a session ends.
• The Session_End event is raised only when the sessionstate mode is set to InProc in the
Web.config file.
• If session mode is set to StateServer or SQLServer, the event is not raised.
– Application_End
• Triggered when the application comes to an end.