ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application...
-
Upload
morgan-summers -
Category
Documents
-
view
220 -
download
2
Transcript of ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application...
ASP.NET application
Roadmap• ASP.NET file types
• Bin directory
• Application updates
• Simple application from start to finish using a
virtual directory
• Behind the scenes
• Code Behind
• Web Form Inheritance
• Importing namespaces
2www.tech.findforinfo.com
ASP.NET file typesFile Name Description .aspx ASP.NET web pages User Interface and underlying code
.ascx ASP.NET user controls,used to create custom controls Inherited to a web page
Web.config XML-based configuration files,which hold settings for application
.cs ,.vb Code behind files,allows to create separate code
Global .asax
File is used to declare global variables and react to global events
.asmx Web services
3www.tech.findforinfo.com
The bin directory
• Every application has a sub directory called as bin
• It holds the .NET assemblies used by your
application
• To say in simple it holds the compiled version of
the code
• Eg database component
4www.tech.findforinfo.com
Application updates
• ASP.NET application easily and painlessly modified without the need of restarting the server
• Page updates
If the code is modified in a page,ASP.NET automatically recompiles an updated version with the next client request and uses caching to improve performance
5www.tech.findforinfo.com
Component updates
• The assemblies in the bin directory can be easily replaced
• ASP.NET continuously monitors the bin directory and creates a new application domain and uses it for the new requests
6www.tech.findforinfo.com
Configuration changes
• The configuration of a web application is defined in the web.config file
• The web.config file holds the information in the XML format
• Once again the new changes are managed by the new application domain
• Easy and editable medium and the changes are rolled back easily
7www.tech.findforinfo.com
Simple application from start to finish
• Create Virtual directory C:\ASP.NET\TestWeb• Go to Control panel->Administrative tools -> IIS-
>Default Web Site• Right click and select New virtual directory
8www.tech.findforinfo.com
• Continue the wizard
9www.tech.findforinfo.com
• Give the alias name as MyFirstWebApp
10www.tech.findforinfo.com
Create a simple code
<html><script language="VB" runat="server"> Public Sub Page_Load() lbltest.Text="Helo" End Sub</script>
<body><form id="Form" runat="server"><asp:Label id="lbltest" runat="server"/></form></body></html>
11www.tech.findforinfo.com
Line by Line with the code
• It consists of two blocks
• Script –holds the code
• Form – holds the asp server controls
• When creating server controls always it is necessary
to use runat=“server” attribute,it specifies the control is
based on the server
12www.tech.findforinfo.com
Behind the scenes
ASP.NET
Web request
IISHandle the request
Is the file reg to ASP.NET
NO
Start the application
Yes
Is the application started
Compile the page
Instantiate the page events
Render to HTML one control at a time
Web response
Yes
Is the page compiled
13www.tech.findforinfo.com
How to run
• Open the explorer• Type http://computername/Virtual
directory name/formname.aspx
14www.tech.findforinfo.com
Code Behind
• Create separate code file(.vb file for VB.NET or.cs file for C#.NET)
• The .aspx file contains the UI and series of HTML code with ASP.NET tags
• The .vb or .cs file contains only code(Logic)
<%@ Page Language=“VB” Inherits =“MyPageClass” Src=“MyPageClass.cs”
Identifies the class Identifies source file
15www.tech.findforinfo.com
The MyPageClass.cs file
• It consists of a class file
Public Class MyPageClassInherits System.Web.UI.Page‘Code goes here’
End Class
16www.tech.findforinfo.com
Inheritance explained
17www.tech.findforinfo.com
Inheritance explained
18www.tech.findforinfo.com
Web form inheritance
Custom .aspxfile
Custom page Class (.cs) Page objectGeneric page
class
System.Web.UI.namespace
19www.tech.findforinfo.com
Three levels of inheritance
• Step 1
• Generic Page class Library available in
the .NET library with the basic functionality
• Step2
• The code behind file(.vb or.cs file) inherits from
the Page class to accquire the basic set of
ASP.NET web page
20www.tech.findforinfo.com
Three levels of inheritance
• Step 3
• Finally the .aspx file inherits the code from the
code behind file to combine the user interface
with the code
21www.tech.findforinfo.com
Importing namespaces
• The namespaces can be added into the code using
• “imports” keyword in vb”
• • “using” keyword in C#
• Alternative way is to add in directives
Imports System.Data.Oledb
Imports System.Data.Oledb
<%@Import Namespace=“System.Web.UI” %>
22www.tech.findforinfo.com
Accessing Code Behind
• Better Organization
• Often ASP.NET is combined with html and asp code
• The code behind provides a neat encapsulation of the code in
a class
• Separation of User Interface
• It designed by any third party tools like Microsoft Frontpage or
Macromedia Dreamweaver
• The ability to use advanced code editors
• Notepad
• Visual Studio .Net editor
• (Intellisense provides automatic statement completion)
23www.tech.findforinfo.com
Three ways to Code Web Form
Development Type
You Create You Deploy(to the server)
Traditional inline code
.aspx .aspx file
Code Behind .aspx files with .vb code
.aspx and .vb files
Compiled Code Behind
.aspx files with .vb code
.aspx files and the compiled .dll files
24www.tech.findforinfo.com