0% found this document useful (0 votes)
25 views130 pages

Server-Side Scripting with PHP and ASP.NET

Uploaded by

Gauri Gaikwad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views130 pages

Server-Side Scripting with PHP and ASP.NET

Uploaded by

Gauri Gaikwad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Web Technology

Unit- V
Server Side Scripting Languages
PHP, WAP & WML, [Link], NodeJS
Syllabus

PHP :
● Introduction to PHP, uses of
PHP,
● general syntactic [Link]
characteristics,
● Primitives, operations ● Overview of
and expressions, the .NET WAP & WML
output, Framework,
● Overview of Overview of Node
● control statements,
C#, JS.
● arrays,
● functions,
● Introduction
● pattern matching, to [Link],
● form handling,
● [Link]
● files, Controls,
● cookies, session ● Web Services
PH
P
Outline
Introduction to PHP,

Features,

sample code,

PHP script working,

PHP syntax,

conditions &

Loops, Functions,

String manipulation,

Arrays & Functions,

Form handling,

Cookies & Sessions,

using MySQL with


Introduction to PHP

● PHP is an acronym for "PHP: Hypertext Preprocessor"


● PHP is a widely-used, open source scripting language
● PHP scripts are executed on the server
● PHP is free to download and use
● What is a PHP File?
● PHP files can contain text, HTML, CSS, JavaScript, and PHP code
● PHP code are executed on the server, and the result is returned to the browser as
plain HTML
● PHP files have extension ".php"
Introduction to
PHP

● What Can PHP Do?


● PHP can generate dynamic page content
● PHP can create, open, read, write, delete, and close files on the server
● PHP can collect form data
● PHP can send and receive cookies
● PHP can add, delete, modify data in your database
● PHP can be used to control user-access
● PHP can encrypt data
● With PHP you are not limited to output HTML. You can output images, PDF files, and
even Flash movies. You can also output any text, such as XHTML and XML.

Features of
PHP
● PHP runs on various platforms (Windows, Linux, Unix, Mac OS
X, etc.)
● PHP is compatible with almost all servers used today (Apache,
IIS, etc.)
● PHP supports a wide range of databases
● PHP is free. Download it from the official PHP resource:
[Link]
● PHP is easy to learn and runs efficiently on the server side
PHP
Syntax

Basic PHP Syntax


A PHP script can be placed anywhere in the
document. A PHP script starts with <?php and
ends with ?>:
<?php
// PHP code goes here
?>
The default file extension for PHP files is ".php".
Data Types

Primitives
1 Integer Type
 For displaying the integer value the Integer type is used.
 It is similar to the long data type in C.
 The size is 32 bit.
2 Double Type
 For displaying the real values the double data type is used.
 It includes the numbers with decimal point, exponentiation or both. The
exponent can be represented by E or e followed by integer literal.
 It is not compulsory to have digits before and after the decimal point.
For instance .123 or 123. is allowed in PHP.
Data Types

3. String Type
 There is no character data type in PHP. If the character has to be
represented then it is represented using the string type itself; but in this
case the string is considered to be of length 1.
 The string literals can be defined using either single or double quotes.
 In single quotes the escape sequence or the values of the literals can
not be
recognized by PHP but in double quotes the escape sequences can be
recognized.

4. Boolean Type
 There are only two types of values that can be defined by the Boolean
type and
those are TRUE and FALSE.
sample code –
Example 1 to print Hello World using
PHP

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php
echo "Hello World!";
?>
</body>
</html>
sample code –
Example 2 variable declaration

Out Put
<?php
$txt = "Hello world!"; "Hello world!" 5
$x = 5; 10.5
$y = 10.5;

echo $txt;
echo "<br>";
echo $x;
echo "<br>";
echo $y;
?>
PHP
Variables
● Rules for PHP variables:
○ A variable starts with the $ sign, followed by the name of the
variable
○ A variable name must start with a letter or the underscore
character
○ A variable name cannot start with a number
○ A variable name can only contain alpha-numeric characters
and underscores (A-z, 0-9, and _ )
○ Variable names are case-sensitive ($age and $AGE are two
sample code –
Example 3- To output text and a variable

<?php <?php
$txt = "[Link]"; $txt = "[Link]";
echo "I love $txt"; echo "I love " . $txt . ;
?> ?>
Program for addition of two numbers

<?php
$n1=5;
$n2=6;
$sum=$n1+$n2;
Echo “Summation is”.$sum;
?>
PHP Variables
Scope

● In PHP, variables can be declared anywhere in the script.


● The scope of a variable is the part of the script where the
variable can be referenced/used.
● PHP has three different variable scopes:
○ local
○ global
○ static
PHP Variables Scope-
Global and Local Scope
Examp Outp
le
<?php
$x = 5; // global scope ut is:
Variable x inside function
Variable x outside function is: 5
function myTest() {
echo "Variable x inside function is: $x";
}

myTest();

echo "Variable x outside function is: $x”;


?>

A variable declared outside a function has a GLOBAL SCOPE and can only be accessed
PHP Variables Scope-
Global and Local Scope
Example Out
<?php
function myTest() put
{
$x = 5; // local scope Variable x inside function is: 5
echo "Variable x inside function is: Variable x outside function is:
$x";
}
myTest();
echo "Variable x outside
function is: $x";
?>

A variable declared within a function has a LOCAL SCOPE and can only be accessed within
that function:
PHP Variables Scope-
The global Keyword
Example Outp
<?php
$x = 5; ut 15
$y = 10;

function myTest() {
global $x, $y;
$y = $x + $y;
}

myTest(); // run function


echo $y; // output the new value for
variable $y
?>
The global keyword is used to access a global variable from within a function
PHP Comparison
Operators
Operato Name Example Result
r
== Equal $x == Returns true if $x is equal to $y
$y
=== Identical $x === Returns true if $x is equal to $y, and they are
$y of the same type
!= <> Not equal $x != $y Returns true if $x is not equal to $y
> Greater than $x > $y Returns true if $x is greater than $y
< Less than $x < $y Returns true if $x is less than $y
>= Greater than or $x >= Returns true if $x is greater than or equal to
equal to $y $y
<= Less than or equal $x <= Returns true if $x is less than or equal to $y
Outline
Introduction to PHP,

Features,

sample code,

PHP script working,

PHP syntax,

conditions & Loops,

Functions,

String manipulation,

Arrays & Functions,

Form handling,

Cookies & Sessions,

using MySQL with PHP,


Conditions and Loops

•If else
•Elseif
Conditional
ladder
Statements
•Switch
•case
While
•Do while
Loop •For
Statements •Foreach
If…else

Syntax Example

<?php
If(condition)
$n=5;
statements; If($n%2 == 0)
else Echo “Number is Even”;
statements; Else
Echo “Number is Odd”;
?>
Elsei
f
Syntax Example

<?php
If(condition) $day=date(“l”);
statements; If($day == “Saturday”))
Elseif(condition) echo “Happy Weekend”;
Elseif($day == “Sunday”))
statements; echo “Happy Sunday”;
Else Else
echo “Nice Working day”;
statements; ?>
Switch case
Example
<?php
$favcolor = “red";
Syntax switch ($favcolor) {
case "red":
Switch(expression) echo "Your favorite color is
{ red!"; break;
Case
case "blue":
constant_expressi
echo "Your favorite color is
on: statements;
break; blue!"; break;
Default:
statement default:
s; echo "Your favorite color is
} neither red, blue!";
} ?>
While Loop

Syntax Example

<?php
while (condition is true)
$x = 1;
{
code to be executed; while($x <= 5) {
} echo "The number is: $x <br>";
$x++;
}
?>
Do-While Loop

Syntax Example
<?php
do { $x = 1;
code to be do {
executed; echo
"The
} while (condition is
number
true); is: $x
<br>";
$x++;
For
Loop
Syntax Example
<?php
for (init counter; test counter;
increment counter) for ($x = 0; $x <= 10;
$x++)
{
{
code to be executed;
echo "The number is:
}
$x <br>";
}
Foreach Loop

Syntax Example
<?php
foreach ($array as
$colors = array("red", green", "blue");
$value) { code
foreach ($colors as $value)
to be executed; {
} echo "$value <br>";
}
?>
Outline
Introduction to PHP,

Features,

sample code,

PHP script working,

PHP syntax,

conditions & Loops,

Functions,

String manipulation,

Arrays & Functions,

Form handling,

Cookies & Sessions,

using MySQL with PHP,


User Defined
Functions
Syntax Example

function <?php
function
functionName() { writeMsg() {
code to be echo "Hello
executed; world!";
} }
writeMsg();
?>
Parameterized Functions

Example Output

<?php
Sum is
function Add($a,$b) { 30
$sum=$a+$b;
echo “Sum is
$sum";
} Add(10,20);
?>
Returning value through function

Example Output

<?php
function Add($a,$b) { Sum is
$sum=$a+$b; 30
return $sum;
}
$Result=Add(10,20);
echo “Sum is $Result";
?>
Setting default values for function parameter

Example Output

<?php
function Add($a,
$b=300)
Sum is 130
{
$sum=$a+$b;
Sum is 30
echo “Sum is $sum";
}
Add(10);
Add(10,20);
Dynamic Function Calls

Example Output
<?php
Hello How
function Hello() { R U?
echo "Hello How R
U?";
}
$fh = "Hello";
$fh();
?>
Outline
Introduction to PHP,

Features,

sample code,

PHP script working,

PHP syntax,

conditions & Loops,

Functions,

String manipulation,

Arrays & Functions,

Form handling,

Cookies & Sessions,

using MySQL with PHP,


String Manipulation

String Function Description Example


strlen() returns the length of a <?php
string echo strlen("Hello world!"); ?> // outputs 12
str_word_count() counts the number of <?php
words echo str_word_count("Hello world!"); ?> //
outputs 2
strrev() reverses a string <?php
echo strrev("Hello world!"); ?>
// outputs !dlrow olleH
strpos() searches for a specific <?php
text echo strpos("Hello world!", "world"); ?> //
within a string. outputs 6
str_replace() replaces some <?php
characters with echo str_replace(“Ram", “Holly", "Hello
Outline
Introduction to PHP,

Features,

sample code,

PHP script working,

PHP syntax,

conditions & Loops,

Functions,

String manipulation,

Arrays & Functions,

Form handling,

Cookies & Sessions,

using MySQL with PHP,


Arrays

Create an Array in PHP


● In PHP, the array() function is used to
create an array:
○array();
● In PHP, there are three types of arrays:
○ Indexed arrays - Arrays with a numeric
index
○ Associative arrays - Arrays with named keys
○ Multidimensional arrays - Arrays containing
Arrays- Indexed Arrays

● There are two ways to create indexed


arrays:
● The index can be assigned automatically
as below :
○ $cars = array("Volvo", "BMW", "Toyota");
● The index can be assigned manually:
○ $cars[0] = "Volvo";
$cars[1] = "BMW";
$cars[2] = "Toyota";
Arrays- Indexed Arrays

● To create and print array Example-


<?php
$cars = array("Volvo", "BMW",
"Toyota");
echo "I like " . $cars[0] . ", " .
$cars[1] . " and " . $cars[2] . ".";
?>
● Get The Length of an Array - The count() Function
Example
● <?php
$cars = array("Volvo", "BMW", "Toyota");
echo count($cars);
Arrays- Indexed Arrays

Loop Through an Indexed <?php


Array Example $cars = array("Volvo", "BMW",
<?php "Toyota");
$cars = array("Volvo", foreach($cars as
"BMW", "Toyota"); $a) { echo $a;
$arrlength = count($cars); } ?>

for($x = 0; $x < $arrlength;


$x++) { echo $cars[$x];
echo "<br>";
Arrays- Associative Arrays

● Associative arrays are arrays that use named keys


that you assign to them.
● There are two ways to create an associative array:
● Method -1
$age = array("Peter"=>"35", "Ben"=>"37");
● Method- 2
$age['Peter'] = "35";
$age['Ben'] = "37";
Arrays- Associative Arrays

Example
<?php
$age = array("Peter"=>"35", "Ben"=>"37",
"Joe"=>"43"); echo "Peter is " . $age['Peter'] . "
years old.";
?>
Loop Through an Associative Array
Example
<?php
$age = array("Peter"=>"35", "Ben"=>"37",
"Joe"=>"43"); foreach($age as $x => $x_value) {
echo "Key=" . $x . "Value=" . $x_value;
Arrays- Multidimensional Arrays

PHP understands multidimensional arrays that are two, three, four, five,
or more levels deep.
PHP - Two-dimensional Arrays: A two-dimensional array is an
array of arrays First, take a look at the following table:
Name Stock Sold
Volvo 22 18
BMW 15 13

Example
$cars = array
( array("Volvo",22,18
),
Functions on Array

● print_r() –Prints all elements of an array in standard


format
● extract()-Converts array into variables
● compact()-Converts group of variables into array
● is_array() –to check weather a particular elements is an
array or not.
● sort() - sort arrays in ascending order
● rsort() - sort arrays in descending order,
● asort()-sorts associative arrays in ascending order, on
values
● ksort()-sorts associative arrays in ascending order,on
keys
●Functions on Array: print_r()
Prints all elements of an array in standard format

Example Output
Array
<?php (
$a = [a] => apple
array ('a' => 'apple', 'b' => [b] => banana
'banana‘) print_r ($a); )
?>
●Functions on Array: extract()
Converts array into variables

Example Output
<?php
$my_array = array(“Rno" =>
1
“1",
Anna
“ Name" => “Anna", TE Comp
“Class" => “TE Comp");
extract($my_array); echo
$Rno;
echo $Name; echo
$Class;
Functions on Array: compact()
Converts group of variables into array

Example Output
<?php
$firstname = "Peter";
Array
$lastname = "Griffin";
(
$age = "41";
[firstname] => Peter
[lastname] =>
$result = compact("firstname",
Griffin [age] => 41
)
"lastname", "age");
Functions on Array: sort()

<?php
$numbers = array(4, 6, 2, 22, 11);

sort($numbers); //sort in ascending order


print_r
($numbers);
//sort in descending order
rsort($numbers);
print_r
($numbers);
Outline
Introduction to PHP,

Features,

sample code,

PHP script working,

PHP syntax,

conditions & Loops,

Functions,

String manipulation,

Arrays & Functions,

Form handling,

Cookies & Sessions,

using MySQL with PHP,


Form Handling- using Post
Method

[Link] [Link]

<form action="[Link]"
method="post"> Name: Welcome
<input type="text" <?php
name="t1"> echo $_POST["t1"];
<br> ?>
<input type="submit">
</form>
Form Handling- using Get Method

[Link] [Link]

<form action="[Link]"
method=“get"> Name: Welcome
<input type="text" <?php
name="t1"> echo $_GET[“t1"];
<input type="submit"> ?>
</form>
Form Handling-
Difference between get and post method
$_GET is an array of variables passed to the current script via the URL
parameters.
$_POST is an array of variables passed to the current script via the HTTP POST
method.

When to use GET?


Information sent from a form with the GET method is visible to everyone. GET
also has limits on the amount of information to send. The limitation is about
2000 characters.

When to use POST?


Information sent from a form with the POST method is invisible to others and
has no limits on the amount of information to send.
Outline
Introduction to PHP,

Features,

sample code,

PHP script working,

PHP syntax,

conditions & Loops,

Functions,

String manipulation,

Arrays & Functions,

Form handling,

Cookies & Sessions,

using MySQL with PHP,


Cookie

● What is a Cookie?
● A cookie is often used to identify a user. A cookie is a small file that the
server embeds on the user's computer. Each time the same computer
requests a page with a browser, it will send the cookie too. With PHP, you
can both create and retrieve cookie values.
● Create Cookies With PHP- is created with the setcookie() function.

● Syntax
● setcookie(name, value, expire, path, domain, secure, httponly);
● Only the name parameter is required. All other parameters are optional.
Cookie-Create/Retrieve a Cookie

<?php
setcookie(“name”, “Amit”, time() + (86400 * 30), "/"); // 86400
= 1 day
?>

<?php if(isset($_COOKIE[“name”]))
{
$nm=$_COOKIE[“name”];
echo “Hello”,$nm;
}
else { echo “Coocke is not set”; } ?
>
Cookie-Modifying a Cookie

To modify a cookie, just set (again)


the cookie using the setcookie()
function:
Cookie- Deleting Cookies

<?php
// set the expiration date to one hour ago
setcookie("user", "", time() - 3600);
?>
<html>
<body>

<?php
echo "Cookie 'user' is deleted.";
?>

</body>
</html>
Session
s
● A session is a way to store information (in variables) to be used across multiple
pages.
● Unlike a cookie, the information is not stored on the users computer.
● What is a PHP Session?
● When you work with an application, you open it, do some changes, and then
you close it. This is much like a Session. The computer knows who you are. It
knows when you start the application and when you end. But on the internet
there is one problem: the web server does not know who you are or what you
do, because the HTTP address doesn't maintain state.
● Session variables solve this problem by storing user information to be used
across multiple pages (e.g. username, favorite color, etc). By default,
session variables last until the user closes the browser.
● So; Session variables hold information about one single user, and are
available to all pages in one application.
Sessions- Start a
Session
● A session is started with the session_start() function.
● Session variables are set with the PHP global variable:
$_SESSION.
● Example - demo_session1.php
<?php
session_start(); // Start the session ?>
<html>
<body>
<?php
$_SESSION["favcolor"] = "green"; // Set session variable
echo "Session variables are set."; ?>
</body>
</html>
Sessions: Get Session Variable Values

● Next, we create another page called "demo_session2.php". From this page, we


will access the session information we set on the first page
("demo_session1.php").
● session variable values are stored in the global $_SESSION variable
● Example- demo_session2.php
○ <?php
session_start(); ?>
<html>
<body>
<?php
// Echo session variables that were set on previous page
echo "Favorite color is ". $_SESSION["favcolor"];
?>
</body>
Sessions- Modify a
Session
To change a session variable, just overwrite it:

<?php
session_start(); ?>
<html>
<body>
<?php
// to change a session variable, just overwrite it
$_SESSION["favcolor"] = "yellow";
print_r($_SESSION);
?>
</body>
</html>
Sessions: Destroy a Session

To remove all global session variables and destroy the session, use
session_unset() and session_destroy():
Example-
<?php
session_start(); ?>

<html>
<body>

<?php
session_unset(); // remove all session
session_destroy(); variables
?> // destroy the session

</body>
Outline
Introduction to PHP,

Features,

sample code,

PHP script working,

PHP syntax,

conditions & Loops,

Functions,

String manipulation,

Arrays & Functions,

Form handling,

Cookies & Sessions,

Using MySQL with


PHP,
MYSQL connectivity using PHP
Open a Connection to MySQL
[Link]

<?php
// Create connection
//$conn = new mysqli($servername, $username, $password,
$dbname);
$conn = new mysqli(“localhost”, “root”, “”);
//MySǪLi extension (the "i" stands for improved)

// Check connection if(!$conn){


die('Could not connect:
'.mysqli_connect_error());
}
echo 'Connected successfully<br/>';
Select Data From a MySQL Database

<?php
$conn = mysqli_connect(‘localhost’, ‘root’, ‘root’,
‘db1’); if(!$conn){
die(mysqli_connect_error());
}
echo 'Connected successfully<br>';

$sql = 'SELECT * FROM STUD';


$rs=mysqli_query($conn, $sql);
$nrows= mysqli_num_rows($rs); ?>
Select Data From a MySǪL Database

if($nrows > 0) {
while($row =
mysqli_fetch_assoc($rs)){
echo "ID :{$row['id']}
<br>"; echo"FNAME : {$row['firstname']} <br>";
echo"LNAME : {$row['lastname']} <br>";
echo "--------------------------------<br>";
}
}
else { echo “ No result"; }
mysqli_close($conn);
?>
Refer pdf shared for more operations on Mysql connectivity
WAP &
WML
WAP(Wireless Application
Protocol) -Introduction
The basic aim of WAP is to provide a web-like experience on
small portable devices - like mobile phones and PDAs
WAP -Introduction
● Purpose of WAP
To enable easy, fast delivery of relevant information and services to
mobile users.
● Type of devices that use WAP
Handheld digital wireless devices such as mobile phones, pagers, two-
way radios, smart phones and communicators -- from low-end to high-
end.
● Type of OS that use WAP
It can be built on any operating system including Palm OS, EPOC
32,Windows CE, FLEXOSs
Refer for WAP architecture in details-
Components of WAP Architecture

Application Layer (WAE)


Other Services
And Applications
Session Layer (WSP)

Transaction Layer (WTP)

Security Layer (WTLS)

Transport Layer (WDP)

Bearers :
CDM IS-1 CDP PDC- Etc
GSM PHS FLEX
A 36 D P …
In detail component of WAP
Wireless Application Environment (WAE): This layer is responsible for defining the
application environment and user interface for WAP. It includes:
Wireless Markup Language (WML): A language similar to HTML but designed for mobile devices. It allows the
creation of pages that can be easily viewed on small screens.

WMLScript: A scripting language used to create dynamic content and interactive applications within WML pages.

Wireless Session Protocol (WSP): Manages the session between the mobile device and the
WAP Gateway. It ensures that data is transmitted correctly and efficiently.

Wireless Transaction Protocol (WTP): Provides transaction support for WAP. It handles the
reliability and ordering of messages between the mobile device and the WAP server.

Wireless Transport Layer Security (WTLS): Ensures secure communication between the
mobile device and the WAP server by providing encryption and authentication.

Wireless Datagram Protocol (WDP): Handles the transport of data over the wireless network.
It is similar to the Internet Protocol (IP) used in traditional web communications
Wireless Application Environment
(WAE) - components

•Addressing model –uses URL & URI

•WML(Wireless Markup Language )- similar


feature like HTML
•WML script –For user I/P validation

•WTA(Wireless Telephony Application)


WML-Wireless Markup Language

● WML is the markup language defined in the WAP specification. WAP sites
are written in WML, while web sites are written in HTML. WML is very
similar to HTML. Both of them use tags and are written in plain text format.

● WML (Wireless Markup Language), formerly called HDML (Handheld Devices


Markup Languages), is a language that allows the text portions of Web pages
to be presented on cellular telephones and personal digital assistants
(PDAs) via wireless access.
While WML itself is client-side, it could be enhanced with
WMLScript, which is a client-side scripting language similar to
JavaScript, allowing for more dynamic and interactive content on
WML pages.
Wireless Markup Language

WML follows a deck and card.

•A WML document is made up of multiple cards.


•Cards can be grouped together into a deck.

A WML deck is similar to an HTML page.

•A user navigates with the WML browser through a series of


WML cards.
WML Elements
<p> </p> text

<a href=...> </a> hyperlink (anchor)

<do> </do> action

<go href=.../> goto wml page

<timer> trigger event (units = tenths of a

<input/> second) input user text

<prev/> return to previous page

$(…) value of variable display

<img src=… /> image

<postfield name=… set variable


value=…/>
<select > <option> <option> </select> select option
WML Structure

< ? xml version=“1.0” ? >


<!DOCTYPE wml …>
<wml>
<card>
<p>
Text….
</p>
<p>
Text……
</p>
</card>
<card>
...
</card>
</wml>
WML Example

<?xml version="1.0"?>
<wml>
<card id="one" title="First Card">
<p>
This is the first card in the deck
</p>
</card>
<card id="two" title="Second Card">
<p>
Ths is the second card in the deck
</p>
</card>
</wml>
WML
Scripts
● WMLScript (Wireless Markup Language Script) is the client-side
scripting language of WML
(Wireless Markup Language).
● A scripting language is similar to a programming language, but is
of lighter weight.

● With WMLScript, the wireless device can do some of the


processing and computation.

● This reduces the number of requests and responses to/from the


WAP Applications

● Banking:
● Finance:
● Shopping:
● Ticketing:
● Entertainment:
● Weather:
● E- Messaging:
[Link]
ASP.N
ET
● Overview of the .NET Framework,
● Overview of C#,
● Introduction to [Link],
● [Link] Controls,
● Web Services
.NET
history
● .NET Framework supports more than 60 programming languages in
which 11 programming languages are designed and developed by
Microsoft. The remaining Non-Microsoft Languages are
supported by .NET Framework but not designed and developed
by Microsoft.
● There are three significant phases of the development of .NET
technology.
○ OLE Technology
○ COM Technology
.NET
history
.NET
history
● The .Net framework was meant to create applications, which
would run on the Windows Platform.
● The first version of the .Net framework was released in the year
2002.
● The version was called .Net framework 1.0. The Microsoft .Net
framework has come a long way since then, and the current
version is .Net Framework 4.7.2.
● The Microsoft .Net framework can be used to create both –
Form-based and Web-based applications.
● Web services can also be developed using the .Net
.NET history
11 Programming Languages which are designed and
developed by Microsoft are:
C#.NET
[Link]
C++.NET
J#.NET
F#.NET
[Link]
T
WINDOWS
POWERSHELL IRON
RUBY
IRON
PYTHON C
OMEGA
ASML(Abstra
How does [Link] Works ?
Step 1 : When user demands for the [Link] file, the web
browser of the client’s PC
sends this request to IIS server.
Step 2 : The IIS server passes this request to .NET Engine.
Step 3 : The .NET engine reads the file line by line and generates
the script in a file.
Step 4 : The requested .NET file is returned to the web browser.
.NET Framework
Architecture

● .Net Framework Architecture is a programming model for


the .Net platform that provides an execution
environment and integration with various programming
languages for simple development and deployment of
various Windows and desktop applications.
● It consists of class libraries and reusable components.
Architecture of .NET Framework

The .NET framework architecture consists of three major


components -
1. CLR
2. Library
3. Language
.NET Framework
Architecture

[Link] Language Runtime


The “Common Language Infrastructure” or CLI is a platform
in .Net architecture on which the .Net programs are executed.

The CLI has the following key features:


1. Exception Handling
2. Garbage Collection
3. Language
4. Compiler
5. Common Language Interpreter
.NET Framework
Architecture

2. Class Library
● The .NET Framework includes a set of standard class libraries.
● A class library is a collection of methods and functions that can
be used for the core purpose.

○ For example, there is a class library with methods to handle


all file-level operations.
○ So there is a method which can be used to read the text
from a file.
○ Similarly, there is a method to write text to a file.
.NET Framework
Architecture
[Link]
The types of applications that can be built in the .Net framework is
classified broadly into the following categories.

1. WinForms – This is used for developing Forms-based


applications, which would run on an end user machine. Notepad
is an example of a client-based application.
2. [Link] – This is used for developing web-based applications,
which are made to run on any browser such as Internet
Explorer, Chrome or Firefox.
3. [Link] – This technology is used to develop applications to
interact with Databases such as Oracle or Microsoft SQL
Overview of C#
C# introduction

What is C#?
C# is pronounced "C-Sharp".

It is an object-oriented programming language created by Microsoft

that runs on the .NET Framework. C# has roots from the C family, and

the language is close to other popular languages like C++ and Java.

The first version was released in year 2002.


C# introduction

C# is used for:
● Mobile applications
● Desktop applications
● Web applications
● Web services
● Web sites
● Games
● VR
● Database applications
● And much, much
more!
C# -Example

[Link]
using System;
namespace
HelloWorld
{
class Program
{
static void
Main(string[]
args)
{
[Link]
teLine("Hell
C#- Example Explained
Example explained
● Using System means that we can use classes from the System namespace.
● namespace is used to organize your code, and it is a container for classes
and other namespaces.
● class is a container for data and methods, which brings functionality to your
program.
● Another thing that always appear in a C# program, is the Main method.
● Console is a class of the System namespace, which has a WriteLine() method
that is used to output/print text.
● If you omit the using System line, you would have to write
[Link]() to print/output text.
C# Variables
int - stores integers (whole numbers), without decimals, such as 123 or -123
(int myNum = 5; )
double - stores floating point numbers, with decimals, such as 19.99 or -19.99
(double myDoubleNum = 5.99D;)
char - stores single characters, such as 'a' or 'B'. Char values are surrounded by
single quotes (char myLetter = 'D'; )
string - stores text, such as "Hello World". String values are surrounded by double
quotes (string myText = "Hello"; )
bool - stores values with two states: true or false (bool myBool = true; )
C# Variables

Syntax
type variableName = value;
Example
string name = "John"; Display
Variables Example string name =
"John";
[Link]("Hello " + name);
Declare Many Variables
int x = 5, y = 6, z = 50;
c#- Get User Input

Use [Link]() to get user input.

Example
[Link]("Enter username:");

// Create a string variable and get user input from the

keyboard and store it in the variable string userName =

[Link]();
C# Assignment Operators
C# Conditional Statements
C# has the following conditional statements:

● Use if to specify a block of code to be executed, if a specified


condition is true

● Use else to specify a block of code to be executed, if the same


condition is false

● Use else if to specify a new condition to test, if the first condition


is false

● Use switch to specify many alternative blocks of code to be


Creating First C# Program

Step 1 : Open Visual Studio. Click on ‘Create a new Project’


step 2 : Select Console application and then click on Next button.
Step 3 : Give any suitable name to your project. I have given the
name as MyFirstApplication.
Step 4 : The source code window will appear now. This window
contains the default C# code. We can write our first C# code as
given in next slide.
Step 5 : run the code to display output.
Run the program by pressing the F5 button on your keyboard (or click on
"Debug" -> "Start Debugging")

After creating project write following code in


program. Cs file and run the code to dispay output

[Link]
using System;

namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
[Link](“welcome User!!!!");
}
}
}
Refer following link to create first C# program
using Visual studio or VS code IDE

[Link]
[Link]
[Link] introduction

AS
P
Acti Serv Pag
ve er es
[Link] introduction
● [Link] is a web application framework developed and marketed by Microsoft
to allow programmers to
build dynamic web sites.
[Link] is a platform for developing web applications. It works on HTTP protocol
and makes use of HTTP commands.
● ASP is a development framework for building web pages.
● ASP supports many different development models:
○ Classic ASP
○ [Link] Web Forms
○ [Link] MVC
○ [Link] Web Pages
○ [Link] API
[Link] introduction

The [Link] application codes can be written in any of


the following languages:
● C#
● Visual [Link]
● Jscript
● J#
[Link] introduction
ASP supports a lot of development models which are as follows:
1. Classic ASP: It is the first server side scripting language developed by Microsoft.
2. [Link]: It is web development framework
3. [Link] Core:, it is considered as an important redesign of [Link] with the
feature of open-source and cross-platform.
4. [Link] Web Forms: These are the event-driven application model which are not
considered a part of the new [Link] Core. These are used to provide the server-
side events and controls to develop a web application.
5. [Link] MVC: It is the Model-View-Controller application model which can be
merged with the new [Link] Core. It is used to build dynamic websites as it
provides fast development.
6. [Link] Web Pages: These are the single page application which can be merged
into [Link] Core.
7. [Link] API: It is the Web Application Programming Interface(API).
[Link] Life
Cycle
[Link] life cycle specifies, how:

● [Link] processes pages to produce dynamic output


● The application and its pages are instantiated and
processed
● [Link] compiles the pages dynamically

The [Link] life cycle could be divided into two groups:

1. Application Life Cycle


2. Page Life Cycle
[Link] Phase
The Application life cycle phases are:
1. Request Phase a)Response objects are created.
a) User makes a request for accessing b) There are some application objects of the class
particular resource. HttpContext, HttpRequest and
HttpResponse. These objects are initialized.
b) Browser sends this request to the web c) The request is processed by the HttpApplication class.
server. Hence an instance of the HttpApplication object is
c) An object of ApplicationManager class is created and assigned to the request.
created. d)Different events are raised by this HttpApplication class
for processing the
d) An object of the HostingEnvironment
request..
class is created to provide information
regarding the resources.
e) Required items in the application are
[Link] Life
Cycle
The page life cycle phases are:
1. Page Request
2. Start
3. Initialization
4. Load
5. Postback event handling
6. Rendering
7. Unloading
[Link] - Basic Controls

1. Button Controls
2. Text Boxes and Labels
3. Check Boxes and Radio Buttons
4. List Controls
5. The ListItemCollection
6. HyperLink Control
7. Image Control
How to Create Web Form Application ?

Step1:Start an instance of Visual Studio 2019 and create a new Web


Application Project by clicking Create a New Project. Locate [Link] Web
Application (.NET Framework)
Click on Next button. Give the suitable project name.
Click on Create button. Then Select Empty project.
Step 2 : Now in the Solution Explorer window, right click on the project
name
Add->new item
then Select the Web Form, and then click Add button.
Step 3 : The default code for [Link] will be displayed in the
Source code window. We can add the user controls using Toolbox.
If we double click on some control, then the code for the user control will
appear in the source code window.
For [Link] we want to insert a text box then,

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="[Link]"


Inherits="UserControlsDemo.WebForm1" %>

<!DOCTYPE html>

<html xmlns="[Link]
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<b> User Name:</b>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
Step 4 : The above web from can be executed on IIS Express
server. Click on the IIS Express option present below the menu
bar.

Output-
• we can select the controls from the ToolBox under the Standard option.
Click and drag the desired controls on the form.

• The most commonly used controls are Button, TextBoxes, Labels,


Checkboxes, ListBoxes and so on.
• A sample form is designed as follows by simply dragging the controls.
[Link] Web Services

A web service is a web-based functionality accessed using


the protocols of the web to be used by the web
applications.

There are three aspects of web service development:


1. Creating the web service
2. Creating a proxy
3. Consuming the web service
• Web service is a software program using which the information can be
exchanged.
• That means using web service one application can invoke the method
another application.
• The web services make use of the standard protocols such as HTTP,
XML and SOAP.
• Features
• 1) Web service is a language independent.
• 2) It is platform independent.
• 3) It is based on XML.
• 4) It is discoverable. That means, applications and developers can
search for and
• locate the desired web services through registries.
• 5) It is based on a stateless service architecture.
Steps to create a web service
For writing the web services, [Link] Web application (.NET Framework) is used

https
://[Link]/UploadFile/29d7e0/steps-to-create-a-si
mple-web-service-and-use-it-in-Asp-Net
/
NodeJS
[Link] :
Overview

● [Link] is an open source server environment


● [Link] is free
● [Link] runs on various platforms (Windows,
Linux, Unix, Mac OS X, etc.)
● [Link] uses JavaScript on the server
[Link] :
Overview
What Can [Link] Do?
● [Link] can generate dynamic page content
● [Link] can create, open, read, write, delete, and close files
on the server
● [Link] can collect form data
● [Link] can add, delete, modify data in your database
What is a [Link] File?
● [Link] files contain tasks that will be executed on certain
events
● A typical event is someone trying to access a port on the
server
Features of Node JS

1) Non blocking thread execution : Non blocking means while we are


waiting for a
response for something during our execution of tasks, we can continue
executing
the next tasks in the stack.
2) Efficient : The [Link] is built on V8 JavaScript engine and it is very
fast in code
execution.
3) Open source packages : The Node community is enormous and the
number of
permissive open source projects available to help in developing your
application
in much faster manner.
Why [Link]?

How PHP or ASP handles a file request: How [Link] handles a file request:

[Link] the task to the computer's file [Link] the task to the computer's file
system. system.
[Link] while the file system opens [Link] to handle the next request.

and reads the file. [Link] the [Link] the file system has opened and read
content to the client. the file, the server returns the content
[Link] to handle the next request.
•[Link] eliminates the waiting, and simply to the client.
continues with the next request.
•[Link] runs single-threaded, non-blocking, asynchronous programming, which is
very memory efficient.

You might also like