asp.net application. roadmap asp.net file types bin directory application updates simple application...

24
ASP.NET application

Upload: morgan-summers

Post on 12-Jan-2016

220 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

ASP.NET application

Page 2: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 3: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 4: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 5: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 6: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 7: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 8: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 9: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

• Continue the wizard

9www.tech.findforinfo.com

Page 10: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

• Give the alias name as MyFirstWebApp

10www.tech.findforinfo.com

Page 11: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 12: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 13: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 14: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

How to run

• Open the explorer• Type http://computername/Virtual

directory name/formname.aspx

14www.tech.findforinfo.com

Page 15: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 16: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 17: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

Inheritance explained

17www.tech.findforinfo.com

Page 18: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

Inheritance explained

18www.tech.findforinfo.com

Page 19: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

Web form inheritance

Custom .aspxfile

Custom page Class (.cs) Page objectGeneric page

class

System.Web.UI.namespace

19www.tech.findforinfo.com

Page 20: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 21: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 22: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 23: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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

Page 24: ASP.NET application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind

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