Professional Documents
Culture Documents
Unit1 ALL
Unit1 ALL
Unit1 ALL
UNIT : 1
INTRODUCTION TO ASP.NET
Types of an applications
1) Desktop applications
2) Mobile applications
3) Web applications
NEED TO CONSUME WEB APPLICATIONS
1) Browser
2) Internet
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
Web server
.NET FRAMEWORK
.NET is not a programming language but it is a
framework(Technology).
Framework:
It is software Infrastructure.
Infrastructure:
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
JIT
2) IL to native code
1) Pre-JIT Compiler
2) Normal JIT Compiler
3) Econo JIT Compiler
.NET FRAMEWORK ARCHITECTURE
MSIL : Microsoft Intermediate language
JIT: Just- in-time
4. Page load
5. Validation (Isvalid)
8. Unload
FEATURES OF .NET IDE
Menu Bar and Toolbar
Solution Explorer
Toolbox
Property window
Using help
Code designers
Component tray
IntelliSense
State management
protected void Button1_Click(object sender, System.EventArgs e) {
TextBox1.Text.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
</head>
<body>
<form id="form1" runat="server">
<div>
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: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)
{
}
}
DIFFERENCE BETWEEN
INTRODUCTION TO WEB-FORMS
Based on Microsoft ASP.NET technology
Compatible
Flexible
ASP.NET WEB FORMS OFFER:
Separation of HTML and other UI code.
InitComplete
PreLoad
Load
LoadComplete
PreRender
PreRenderComplete
SaveStateComplete
UnLoad
ASP.NET BUILT-IN DIRECTORY STRUCTURE
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.
Caching settings
Session States
Error Handling
Security
BENEFITS OF XML-BASED CONFIGURATION FILES
It is human readable.
Need not restart the web server when the settings are
changed in configuration file.
<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.
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
web applications
web services
Efficient
int n1 = 100;
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
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
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#
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
Important terminology:
Super Class
Sub Class
Reusability
INHERITANCE
The symbol used for inheritance is :
Syntax:
}
TYPES OF INHERITANCE IN C#
Single Inheritance
MULTILEVEL INHERITANCE
HIERARCHICAL INHERITANCE
MULTIPLE INHERITANCE
HYBRID INHERITANCE
IMPORTANT FACTS ABOUT INHERITANCE IN C#
Default Superclass
Inheriting Constructors