Unit1 ALL

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 90

SHRI D.N.

INSTITUTE OF COMPUTER APPLICATIONS


B.C.A. SEMESTER – V
US05CBCA21 : ADVANCED WEB DEVELOPMENT
TECHNOLOGY

UNIT : 1
INTRODUCTION TO ASP.NET

Dr. Tamanna Kachwala


SYLLABUS OF UNIT 1
 Introduction To ASP.NET
 Introduction to .NET Platform and Web :

Introduction to ASP (Server-side Technology),.NET Framework (FCL and


CLR),Overview of IIS, Processing of ASP.NET page (Execution model), Features
of .NET IDE, Features of ASP.NET, Working with ASP.NET, Coding Model (Inline
and Code-behind)
Introduction to Web-Forms and its Events ASP.NET Built-in directory structure.
App_data,App_code,Bin

 Application Configuration : Global.asax file, Web.config

 Common properties : AccessKey, BackColor, BorderWidth, BorderStyle, CSSClass,


Enabled, Font, ForeColor, Height, TabIndex, Tooltip, Width, ID, Runat, Text

 Using Visual C# in ASP. NET:


Introduction, Variables, Data Types, Value Types, Scope of Variables, Operators,
OOPs Concepts (Encapsulations, Inheritance, Polymorphism and Abstraction)
INTRODUCTION TO ASP.NET
(SERVER-SIDE TECHNOLOGY)
 ASP. NET is a technology or a application framework from
Microsoft for developing web applications to produce
dynamic web pages.

 Types of an applications

 1) Desktop applications
 2) Mobile applications

 3) Web applications
NEED TO CONSUME WEB APPLICATIONS

 1) Browser
 2) Internet

Different technologies to develop web applications

1) ASP ( VB script)
2) ASP.NET (VB.NET, C#, J#)
3) PHP (PHP script)
4) JSP (Java)
NEED TO DEVELOP WEB APPLICATIONS
 HTML

 CSS

 JAVA script ( client side scripting)

 ASP.NET (server side scripting)

 Web server
.NET FRAMEWORK
 .NET is not a programming language but it is a
framework(Technology).

 Framework:
It is software Infrastructure.
 Infrastructure:

A minimum thing require for development.

Ex: .NET (.NET framework )


JAVA (JAVA framework)
PHP (PHP framework)
.NET FRAMEWORK IS USED TO
DEVELOPMENT
 Console applications
 Windows applications

 Web applications

 Windows services

 Web services

 Assemblies

 websites
WHAT IS FRAMEWORK CONTAINS?
 Runtime

 Built in libraries

 Programming language

 Compliers
FEATURES OF .NET FRAMEWORK
 Multiple language support

 Language interpretable

 Built in libraries

 Powerful framework

 Intelligent application software


WHAT IS IL?
COMPILER IN .NET

 JIT

Every program will be compiled two times.


1) Programming language to IL

2) IL to native code

 Types of Just-In-Time Compiler: 

1) Pre-JIT Compiler
2) Normal JIT Compiler 
3) Econo JIT Compiler
.NET FRAMEWORK ARCHITECTURE
 MSIL : Microsoft Intermediate language
 JIT: Just- in-time

 CLR: Common Language Runtime

 CTS: Common Type System

 FCL: Frame Class Library

 WPF: Windows Presentation Foundation

 LINQ: Language Integrated Query

 WF: Workflow Foundation

 WCF: Window Communication Foundation

 UWP: Universal Window Platform


OVERVIEW OF IIS (WEB SERVER)
 A web server is for hosting web applications.

 IIS is a web server that runs on the Microsoft .NET platform


on the Windows operating system. 

 It is one of the most powerful web servers from Microsoft.

 It is used to host your ASP.NET Web application.

 IIS: Internet Information Services


PROCESSING OF ASP.NET PAGE
(EXECUTION MODEL)
 When a page is requested, it is loaded into the server memory,
processed, and sent to the browser. Then it is unloaded from the
memory. 
STAGES OF PAGE EXECUTION MODEL
 1. Page Request
 2. Start (Request, Response, IsPostBack, UICulture)

 3. Page initialization (UniqueID)

 4. Page load

 5. Validation (Isvalid)

 6. Postback event handling

 7. Page rendering (Render method)

 8. Unload
FEATURES OF .NET IDE
 Menu Bar and Toolbar
 Solution Explorer

 Toolbox

 Property window

 Using help

 Code designers

 Server explorer window

 Component tray

 IntelliSense

 The Output Window

 Object Explorer Window


FEATURES OF ASP.NET
 Separation of Code from HTML
 Support for compiled languages

 Use services provided by the .NET Framework

 Graphical Development Environment

 State management

 Update files while the server is running

 XML-Based Configuration Files


ASP.NET CODING MODELS

 ASP.NET 4.0 provides two types of coding technique.

 Single -File page model / Inline.


 Default.aspx

 Code-behind page model.


 two separate files 1) Default.aspx 
2) Default.aspx.cs 
 
INLINE CODING MODEL (DEFAULT.ASPX)
 <%@ Page Language="C#" %> 
 <script runat="server">

     protected void Button1_Click(object sender, System.EventArgs e) {

         Label1.Text = "Your Name is : " +

             TextBox1.Text.ToString();

     }

 </script>

 <html xmlns="http://www.w3.org/1999/xhtml">

 <head id="Head1" runat="server">

     <title>Asp.Net Inline Coding Model Example</title>

 </head>

 <body>

     <form id="form1" runat="server">

     <div>

              <asp:Label ID="Label2" runat="server" Text="Enter your name:"

             AssociatedControlID="TextBox1"></asp:Label>

         <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

         <br />

         <asp:Button ID="Button1" runat="server" Text="Click" OnClick="Button1_Click" />

     </div>

     </form>

 </body>
CODE-BEHIND PAGE MODEL
1) DEFAULT.ASPX 2)
DEFAULT.ASPX.CS
<
%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inher
its="_Default" %> 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 <html xmlns="http://www.w3.org/1999/xhtml">

 <head runat="server">

     <title>Untitled Page</title>

 </head>

 <body>

     <form id="form1" runat="server">

     <div>

         <asp:Label ID="Label1" runat="server" Text="Enter your name: "></asp:Label>

         <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

         <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click
" />
     </div>

     </form>

 </body>
2)DEFAULT.ASPX.CS
 using System;
 using System.Configuration;

 using System.Data;

 using System.Linq;

 using System.Web;

 using System.Web.UI;

 using System.Web.UI.WebControls;

 public partial class _Default : System.Web.UI.Page
 {

     protected void Page_Load(object sender, EventArgs e)

     {

  

     }

     protected void Button1_Click(object sender, EventArgs e)

     {

         Response.Write("Welcome to our website");

     }

 }
DIFFERENCE BETWEEN
INTRODUCTION TO WEB-FORMS
 Based on Microsoft ASP.NET technology

 Compatible

 Automatically renders the correct browser

 Built on the Microsoft .NET Framework

 Flexible
ASP.NET WEB FORMS OFFER:
 Separation of HTML and other UI code.

 A rich suite of server controls.

 Powerful data binding.

 Support for client-side scripting.

 Support for other capabilities.


ASP.NET WEB FORM EVENTS
 PreInit 
 Init 

 InitComplete  

 PreLoad

 Load 

 LoadComplete 

 PreRender

 PreRenderComplete

 SaveStateComplete 

 UnLoad 
ASP.NET BUILT-IN DIRECTORY STRUCTURE

 App_data (.MDF, .XML)

 App_code (.VB, .CS, .JSL)

 Bin (.DLL)
APPLICATION CONFIGURATION :
1) Web.config 2) Global.asax

Web.config file
 A configuration file (web.config) is used to manage
various settings that define a website.

 a website contains a single Web.config file stored inside


the application root directory

 The settings are stored in XML files that are separate


from your application code.
WEB.CONFIG CONTAINS
 Database connections

 Caching settings

 Session States

 Error Handling

 Security
BENEFITS OF XML-BASED CONFIGURATION FILES

 Information can be stored and retrieved easily.

 It is human readable.

 Need not restart the web server when the settings are
changed in configuration file.

 You can use any standard text editor or XML parser to


create and edit ASP.NET configuration files.
STRUCTURE OF WEB.CONFIG
 <?xml version=“1.0”?>
 <configuration>  

 <configSections>….</configSections>

     <connectionStrings>  

         <add name="myCon" connectionString="server=M
yServer;database=puran;uid=admin;pwd=123">   
   </connectionStrings>  

 <system.web>….</system.web>

 </configuration> 
GLOBAL.ASAX FILE
 Global.asax is an optional file which is used to handling higher
level application events such as Application_Start
Application_End
Session_Start
Session_End etc.
 It is also popularly known as ASP.NET Application File.

 This file resides in the root directory of an ASP.NET-based


application.
COMMON PROPERTIES OF CONTROL
 AccessKey
 BackColor

 BorderWidth

 BorderStyle

 CSSClass

 Enabled

 Font

 ForeColor

 Height

 TabIndex

 Tooltip

 Width

 ID

 Runat

 Text
ACCESSKEY
 Use the AccessKey property to specify the keyboard
shortcut for the Web server control.

Example:

<form runat="server">
<asp:CheckBox id="check1" AccessKey="y"
runat="server" />
</form>
BACKCOLOR
 Asp.net web server control's BackColor property hold a
valid color name.

Example

<form runat="server">
<asp:Button id="button1" Text="Submit"
BackColor="#FFCC80" runat="server" />
</form>
BORDERWIDTH
 Asp.net web server control BorderWidth property accept a
numeric value.

Example
<form runat="server"> <asp:Table runat="server"
BorderWidth="5"> <asp:TableRow>
<asp:TableCell>Hello</asp:TableCell>
<asp:TableCell>World</asp:TableCell> </asp:TableRow>
</asp:Table>
</form>
BORDERSTYLE
 The BorderStyle property is used to set or return the border
style of a control. The different styles are there for ex,
notset, none, dotted, double, solid, dashed etc.

Example
<form runat="server">
<asp:Table runat="server" BorderStyle="dotted"
BorderWidth="5" GridLines="vertical">
  <asp:TableRow>
    <asp:TableCell>Hello</asp:TableCell>
    <asp:TableCell>World</asp:TableCell>
  </asp:TableRow>
</asp:Table>
</form>
CSSCLASS
 It is used to set or return a CSS style class to a control.

Example

<style>
.TestStyle
  {
  font: 12pt verdana;
  font-weight:700;
  color:orange;
  }
</style>

<form runat="server">
<asp:Button id="Button" CssClass="TestStyle"
Text="Submit" runat="server"/></form>
ENABLED
 The Enabled property is used to enable or disable a
control.

Example

<form runat="server“>
<asp:Button id="Button2" Enabled=False
Text="Submit" runat="server"/>
</form>
FONT
 The Font property is used to set or return the font of a
control.

Example

<form runat="server">
<asp:Button id="Button1" Text="Submit"
Font-Name="Verdana" Font-Size="15" runat="server"/>
</form>
FORECOLOR
 The ForeColor property is used to set or return the
foreground color (normally the text color) of a control.

Example

<form runat="server">
<asp:Button id="button1" Text="Submit"
ForeColor="#FF0000" runat="server" />
</form>
HEIGHT
 The Height property is used to set or return the height of a
control.

Example

<form runat="server">
<asp:Button id="button1" Text="Submit"
Height="50px" runat="server" />
</form>
WIDTH
 The Height property is used to set or return the width of
a control.

Example

<form runat="server">
<asp:Button id="button1" Text="Submit"
width="50px" runat="server" />
</form>
TABINDEX
 The TabIndex property is used to set or return the tab
order of a control.

Example

<form runat="server">
<asp:CheckBox id="check1" TabIndex="1"
runat="server" />
</form>
TOOLTIP
 The ToolTip property is used to set or return the text that
appears when the user rests the mouse pointer over a
control.

Example

<form runat="server">
<asp:Button id="button1" Text="Submit" runat="server"
ToolTip="This is an example-button" />
</form>
ID
 The ID property is used to assign an identifier to an
ASP.NET server control which can be later used to
access that control. 

Example

<form runat="server">
<asp:Button id="button1" Text="Submit" runat="server"
/>
</form>
 
RUNAT
 The runat="server" tag in ASP.NET allows the ability to
convert/treat most any HTML element as a server-side
control that you can manipulate via code at generation
time.
TEXT
 It is used to set text to be shown for the control.

Example

<form runat="server">
<asp:Button id="button1" Text="Submit"
runat="server"/>
</form>
VISUAL C# IN ASP. NET
 General-purpose, modern and object-oriented
programming language.
 similar to Java
EXAMPLE: 
A SIMPLE PROGRAM TO PRINT HELLO WORLD
// C# program to print Hello World

using System;
  namespace HelloWorldApp
{   
    class HelloWorld
    {   
                static void Main(string[] args)
        {
                          Console.WriteLine("Hello World");
               Console.ReadKey();
        }
    }
}

Output:
Hello World
APPLICATIONS

 developing desktop applications

 web applications

 web services

 Development of windows operating system (windows 8)


ADVANTAGES OF C#

 Efficient

 Garbage is automatically collected

 High memory backup

 Cost of maintenance is less

 Compiled to a intermediate language


VARIABLES
using System;
namespace Demo
{
class Program
{
static void Main(string[] args)
{
string s1="The value is ";
int i=9 ;
int32 i= 9;
Console.WriteLine(s1+i);
Console.ReadKey();
}
}
}
Output: The value is 9
DATATYPES
 C# is a strongly-typed language.

 Byte, sbyte, short, ushort, int, uint, long, ulong, float,


double, decimal, char, bool, object, string, datetime
EXAMPLE: VARIABLES OF DIFFERENT
DATA TYPES
string str1 = "Hello World!!";

int n1 = 100;

float per = 90.2;

char grade = 'A';

bool pass = true;


VALUE TYPE
Ex:
integer variable int i = 100;
DATA TYPES OF VALUE TYPE

 bool
 byte

 char

 decimal

 double

 enum

 float

 int

 long

 sbyte

 short

 struct

 uint

 ulong

 ushort
REFERENCE TYPE
 Ex:
string s = "Hello World!!";
REFERENCE TYPE DATA TYPES:

 String

 Arrays (even if their elements are value types)

 Class

 Delegate
WHAT IS A DATA TYPE SUFFIX?
 Example:
var myVal2 = 4294967296L;  
var myMoney = 300.5m;  
var myRadius = 3.145f;  

suffix list
 L or l for long

 D or d for double

 F or f for float

 M or m for decimal

 U or u for unsigned integer

 UL or ul for unsigned long


ALIAS VS .NET TYPE
Alias .NET Type

byte System.Byte
sbyte System.SByte
int System.Int32
uint System.UInt32
short System.Int16
ushort System.UInt16
long System.Int64
ulong System.UInt64
float System.Single
double System.Double
char System.Char
bool System.Boolean
object System.Object
string System.String
decimal System.Decimal
DateTime System.DateTime
ALIAS VS .NET TYPE

Example:

int i = 345;
Int32 i = 345;// same as above
DEFAULT VALUES
int i = default(int); // 0
float f = default(float);// 0
decimal d = default(decimal);// 0
bool b = default(bool);// false
char c = default(char);// '\0' 

// C# 7.1 onwards
int i = default; // 0
float f = default;// 0
decimal d = default;// 0
bool b = default;// false
char c = default;// '\0'
SCOPE OF VARIABLES IN C#

 Class Level Scope

 Method Level Scope

 Block Level Scope


CLASS LEVEL SCOPE

using System;
  class GFG
{
    int a = 10;
      public void display()
    {
        Console.WriteLine(a);
      }  
}
METHOD LEVEL SCOPE
using System;
  class GFG {
          public void display()
      {
        int m = 47;
          Console.WriteLine(m);
      }
    public void display1()
      {
        Console.WriteLine(m);
      }
  }
BLOCK LEVEL SCOPE
using System;
class GFG
  {
     public void display()
      {
        int i = 0;
        for (i = 0; i < 4; i++)
{     
            Console.WriteLine(i);
        }
        for (int j = 0; j < 5; j++)
{
                   Console.WriteLine(j);
         }
                 Console.WriteLine(j);
    }
}
OPERATORS
 Arithmetic Operators. A =10 and B = 20
RELATIONAL OPERATORS
ASSUME A =10 AND B = 20
LOGICAL OPERATORS
ASSUME A=TRUE B=FALSE
ASSIGNMENT OPERATOR
CONTINUE….
OOPS CONCEPTS
 Encapsulations
 Inheritance
ENCAPSULATIONS

Advantages of Encapsulation:

•Data Hiding 

•Increased Flexibility 

•Reusability

•Testing code is easy


INHERITANCE
 One class is allowed to inherit the features of another
class.

 Important terminology:

 Super Class
 Sub Class

 Reusability
INHERITANCE
 The symbol used for inheritance is :

Syntax:

class derived-class : base-class


{

// methods and fields

}
TYPES OF INHERITANCE IN C#

 Single Inheritance
MULTILEVEL INHERITANCE
HIERARCHICAL INHERITANCE
MULTIPLE INHERITANCE
HYBRID INHERITANCE
IMPORTANT FACTS ABOUT INHERITANCE IN C#
 

 Default Superclass

 Superclass can only be one

 Inheriting Constructors

 Private member inheritance


POLYMORPHISM

 Having many forms.


 'one interface, multiple functions'.

Types of polymorphism in C#:


ABSTRACTION

 Process of hiding certain details and showing only


essential information to the user.

 Abstraction can be achieved with either abstract class.

You might also like