ASP.NET

What is ASP.NET?
ASP.NET is a framework generally written in one of two languages - VB script or C#.
Environmental Setup:
Visual Studio is IDE used to easily develop DOT NET applications.Follow the below steps to download and install Visual Studio.






Run "Hello World" program  in VB.NET using Visual Studio:
Follow the below steps to create a simple Console application which prints Hello World.




Variables in VB:
Variables are the names given to the actual data to be stored in memory.
Rules:
  • It must begin with an alphabetic character or an underscore.
  • It must only contain alphabetic characters, decimal digits, and underscores.
  • No spacing is allowed.
  • It must not begin with a number.
  • Dot(.) is not allowed.
Declaration Levels:
The scope of a variables depends on the Declaration level. The below are the declaration levels.
Local and Member Variables:
  • A local variable is one that is declared within a procedure and is available only within procedure.
  • A member variable is declared at the class level and is available globally to the class members.
Shared and Instance Variables:
  • Shared variable is declared at class level with Shared keyword. It exists in a single copy shared among all instances of the class.
  • If it is not shared it is an instance variable, and a separate copy of it is created for each instance of the class.
Variable Declaration Scope:
The keyword used to declare a variable and the location in which its declared defines the scope and duration in which a variable is available.
Keyword:
  • The first word used in a variable declaration
Declaration location:
  • "Procedure" means the variable is declared within a Sub, Function.
  • "Module" means the variable is declared near the top of the module, not inside a procedure
Scope:
  • "Procedure" means the variable is available only within the Sub, Function in which it was defined.
  • "Module" means the variable is available only within the module in which it was defined
  • "Project" means the variable is available throughout all modules in the project
Duration:
  • "Procedure" means the variable's value is gone once the procedure its available in has finished
  • "Application" means the variable's value will remain throughout running of the program
Keyword Declaration location Scope Duration
Dim Procedure Procedure Procedure
Static Procedure Procedure Application
Private Module Module Application
Public Module Project Application
Const Procedure Procedure Procedure
Private Const Module Module Application
Public Const Module Project Application
Global Module Project Application
Data Types:
Data types describes what kind of values and storage space a variable holds.
Data Type Size
Byte 1 byte
Short 2 bytes
Integer 4 bytes
Long 8 bytes
Char 2 bytes
String Calculated based on length
Float 4 bytes
Double 8 bytes
Decimal 16 bytes
Date 8 bytes
Boolean 1 byte
Variable Declaration:
  • Syntax: Dim variableName As DataType
  • Example: Dim number As Integer
Variable Initialization:
  • Syntax: Dim variableName As DataType=value
  • Example: Dim number As Integer=10
String Expressions:
  • Declaration Syntax: Dim stringName As String
  • Example: Dim name as String
  • Initialization Syntax: Dim stringName As String = "Enter the string here"
  • Example: Dim name As String = "Keshav Jha"
The following are some basic string manipulation functions.
1. The  Len Function
The length function is used to find out the number of characters in any given string.
Syntax:
Len(string)
2. The Mid function
The mid function is used to Return a substring containing a specified number of characters from a string.
Syntax:
Mid (string, start[, length])
string - String expression from which characters are returned.
start - Character position in string at which the part to be taken begins.
length - Length is Optional. Number of characters to return.
3. The Left Function
The Left function extract the left portion of a string.
Syntax:
Left("string", n)
4. The Right Function
The Right function extract the right portion of a string.
Syntax:
Right("string", n)
5. The Space Function
The space function is used to Return a string containing the specified number of blank spaces.
Syntax:
Space (number)
6. The Replace Function
The replace function is used to replacing some text in a string with some other text.
Syntax:
Replace( string, searchtext, replacetext )
7. The Trim Function
The trim function trims the empty spaces on both side of the String.
Syntax:
Trim ("String")
8. The Ltrim Function
The Ltrim function trims the empty spaces of the left portion of the string.
Syntax:
Ltrim("string")
9. The Rtrim Function
The Rtrim function trims the empty spaces of the Right portion of the string.
Syntax:
Rtrim("string")
10. The Ucase and the Lcase Functions
The Ucase function converts all the characters of a string to capital letters. On the other hand, the Lcase function converts all the characters of a string to small letters.
Syntax:
Ucase("string") or Lcase("string")
Program showing all the above functions:
Module Module1
    Sub Main()
        Dim leng As String = Len(" Keshav Jha")
        Console.WriteLine("length is :" & leng)
        Dim middle As String = Mid("Keshav Jha", 3, 4)
        Console.WriteLine("Mid is :" & middle)
        Dim leftf As String = Left("Keshav Jha", 3)
        Console.WriteLine("Left is:" & leftf)
        Dim rightr As String = Right("Keshav Jha", 6)
        Dim replaces As String = Replace("Keshav Jha", " ", "Kumar")
        Console.WriteLine("Replace is :" & replaces)
        Dim trimt As String = Trim("   Keshav Jha  ")
        Console.WriteLine("Trim is :" & trimt)
        Dim ltriml As String = LTrim("    Keshav Jha     ")
        Console.WriteLine("ltrim is :" & ltriml)
        Dim rtrimr As String = RTrim("    Keshav Jha     ")
        Console.WriteLine("rtrim is :" & rtrimr)
        Dim ucaseu As String = UCase("Keshav Jha")
        Console.WriteLine("Ucase is :" & ucaseu)
        Dim lcasel As String = LCase("Keshav Jha")
        Console.WriteLine("Ucase is :" & lcasel)
    End Sub
End Module

Conditional Statements in VB:
  • Conditional Statements are used to control program flow and to make decisions.
  • There are four types of If control structures:
  • If….Then statement
  • If….Then… Else statement 
  • If….Then….ElseIf ....Else statement.
  • The Select Case…End Select Structure
1.  If….Then Statement:
If the condition is true, the Expressions within the End If will be executed.
Syntax:
If condition Then

Expressions

End If

2. If….Then… Else statement:
The Expressions under the If block are executed based on the condition is true, Otherwise Else block is executed.
Syntax:
If condition Then

Expressions that need to be executed on satisfying the above condition.

Else

Expressions that need to be executed on failing the if condition.

End If

3. If….Then….ElseIf ....Else statement:
In circumstances where there are more than two alternative conditions, we can use the If….Then…ElseIf Statement.
Syntax:
If condition Then

Expressions that need to be executed on satisfying the above condition.

ElseIf condition Then

Expressions that need to be executed on satisfying the above condition.

ElseIf condition Then

Expressions that need to be executed on satisfying the above condition. 

..

Else

Expressions that need to be executed if none of the above conditions are true.

End If

4. The Select Case…End Select Statement:
It is the replace for the above If...Then...ElseIf...Else Statement to overcome the problems in this.
Syntax:
Select Case expression

Case value1

Block of one or more statements

Case value2

Block of one or more statements

Case value3
.
.
Case Else

Block of one or more statements

End Select

The particular block of statements are executed based on matching the expression and values.

Loops:
  • Looping involves a  procedure that runs repetitively until a certain condition is met.
  • There are three types of Loops in .net, they are For…..Next loop, the Do loop, and the While…..End While loop
1. For….Next Loop:
Syntax:
For counter=startNumber to endNumber (Step increment)

One or more statements

Next

In order to exit a For…..Next Loop,we can place the Exit For statement within the loop.

2. Do Loop:
There are several  Do Loop structures, as shown below:
a) Do While condition
Block of one or more statements
Loop

b) Do
Block of one or more statements
Loop While condition

c) Do Until condition
Block of one or more statements
Loop

d) Do
Block of one or more statements
Loop Until condition

We can also use Exit Do to escape the loop.

3.While....End While Loop:
Syntax:
While conditions

Block of one or more statements

End While

Read from User Input and Write to User Output:
Example:


C Programming

Downloading and Installing Compiler:
  • Turbo C/C++ is the both editor and compiler software for C and C++.
  • We can download Turbo C by going to the below site highlighted in the red box in the address bar.








Running Hello C Program:
  • Open Turbo C.
  • Press Ctrl + N to create a new file and save it with .c extension.

  • After writing the code press Alt + F9 to compile.
  • Ctrl + F9 to run the code.
  • Alt + F5 to see the output. 


Variables:
  • Variables are used to store the data.
  • They provide a way to naming data with descriptive name.
  • A variable must be declared before using it.
  • There are certain rules for the declaration of variable.
Rules for Declaration:
  • A variable must start with an alphabet.
  • No spaces are allowed between the characters.
  • Variables are case sensitive.
  • Underscore( _ ) is the only special character allowed.
  • Variables can be combination of alphabets and digits.
  • Variables cannot start with a number.
  • Variables names cannot be C reserved keywords.
Data types:
  • Data types are used to specify what kind of value can be stored in a variable.
  • The memory size and type of value of variable are determined by data type.
  • Each variable or constant or array must have a data type.
  • The data types in C are classified into four categories.
Categories Data Types
Basic data types int, char, float, double
Enumeration data type enum
Derived data type pointer, array, structure, union
Void data type void
Basic data types:
  • Integer, Floating Point and Character types are considered as basic data types.
Integer types:
  • Used to store whole numbers.
TypeSize(bytes)Range
int or signed int2-32,768 to 32767
unsigned int20 to 65535
short int or signed short int2-128 to 127
unsigned short int20 to 255
long int or signed long int4-2,147,483,648 to 2,147,483,647
unsigned long int40 to 4,294,967,295
Floating Point Types:
  • Used to store real numbers.
TypeSize(bytes)Range
Float43.4E-38 to 3.4E+38
double81.7E-308 to 1.7E+308
long double103.4E-4932 to 1.1E+4932
Character Types:
  • Used to store characters.
TypeSize(bytes)Range
char or signed char1-128 to 127
unsigned char10 to 255
Variables Declaration and Initialization:
  • All the variables must be declared before using it.
  • C is a case sensitive language. So name, Name, NAME are all not the same. 
Declaration:
The variable declaration in C can be done as follows:
data_type variable_name;
or
data_type variable_1, variable_2, variable_3........, variable_n;
Example:
int a;
float x,y,z;
char 'ch';
Initialization:
The variable initialization in c can be done as follows:
data_type variable_name=value;
or 
After declaring the variable directly assign the value to the variable.
variable_name=value;
Example:
int a=10;
char ch='k';
String expressions and String functions:
  • String is an array of characters.
  • Strings are enclosed by double quotes.
Syntax:
char string[20]="Keshav Jha";
String functions:
  • There are predefined string handling functions available in string.h header file.
  • These functions include performing operations like comparing, concatenation, finding length and various other manipulations.
  • To use these functions we have to include string.h header file.
The below are some commonly used string function.
  • strcat() – This function is used to con concatenate two strings. 
  • strcmp() – This function is used to compare two strings. 
  • strcpy() – This function h is used to copy the second string given as second parameter to this function into first string. 
  • strlen() – This function is used to length of the string in other words the number of characters present in string . 
  • strstr() – This function is to obtain the first occurrence of substring in a string .
  • strlwr() –This function converts string to lower case.
  • strupr() – This function converts string to upper case.
Conditional Statements:
  • Conditional statements are used to execute a block of statements based on conditions.
  • There are predefined conditional statements which are evaluated to boolean expressions either true or false.
  • If the given condition is true then the block of code inside the body of conditional statement is executed or else it is skipped.
The below are the conditional statements in c:
  • if statement.
  • nested if statement.
  • if else statement.
  • nested if else statement.
  • if-else if ladder.
  • switch statement.
  • goto statement.
  • break statement.
  • continue statement.
1. if statement:
It is used to execute the code if the statement is true.
Syntax:
if(condition){
...........statement_1;
...........statement_2;
...........statement_3;
.
.
...........statement_n;
}
2. nested if statement:
It is used nesting of if statement. An if inside if or multiple ifs form a nested if statement.
Syntax:
if(condition){
if(condition){
// statements to be executed...
}
}
3. if else statement:
If the condition of if block satisfies, then if block is executed. On failing the if condition else block is executed.
Syntax:
if(condition){
//code that has to be executed on satisfying if condition.
}
else{
//code that has to executed on failing the if condition.
}
4. nested if else statement:
Using multiple if conditions inside an if is known as nested if statement.
Syntax:
if(condition){
//code that has to be executed on satisfying immediate above if condition.
if(condition){
//code that has to be executed on satisfying immediate above if condition.
if(condition){
//code that has to be executed on satisfying immediate above if condition.
}
}
}
else{
//code that has to be executed on failing the if conditions.
}
5. if else if ladder:
When a choice has to be made with more than two possibilities if else if ladder is used.
Syntax:
if (condition_1)
{
   //code to be executed if condition_1 is true
}
else if(condition_2)
{
   //code to be executed if condition_1 is false and condition_2 is true
}
else if (condition_3)
{
   //code to be executed if condition_1 and condition_2 is false and condition_3 is true
}
.
.
else
{
   // statements to be executed if all conditions are false
}
6. switch statement:
  • The if else if ladder statement checks for all the conditions and increases the complexity. 
  • To overcome this switch case checks the value of a expression against a case values, if condition matches the case values then the control is transferred to that point.
  Syntax:
switch (expression)
{
  case label_1:
    statements;
  case label_2:
    statements;
    break;
.
.
.
.

  case label_n:
    statements;
    break;
  default:
    statements;

}
Rules for switch case:
  • The default case is optional. When no match is found the default case is executed.
  • The case label should be integer or character constant.
  • Each compound statement of a switch case should contain break statement to exit from case.
  • Case labels must end with (:) colon.

7. break statement:
  • Break Statement is a loop control statement which is used to terminate the loop. 
  • When the break statement is encountered from within a loop, the loop iterations stops there and control returns from the loop immediately to the first statement after the loop.
8. goto statement:
  • The goto statement is a jump statement.
  • It is used to jump from anywhere to anywhere within a function.
Syntax:
goto label;     
.                
.                
.           
label:  
 or
label:
.
.
.
  
goto label;
9. continue statement:
  • The continue statement is a loop control statement.
  • It is opposite to the break statement, instead of terminating the loop, it forces to execute the next iteration of the loop.
Loops in C:
  • Loops are used to repeat a block of code until some end condition is met.
  • There are three different loops in C. They are:
1. for loop:
  • It is considered as open ended loop. 
  • The block of statements inside the loop are repeatedly executed until a test condition is satisfied.
Syntax:
for(initialization; condition; increment/decrement)
{
    statement-block;

}

The for loop is executed as;
1. It first evaluates the initialization code.
2. Then it checks the condition expression.
3. If it is true, it executes the for-loop body.
4. Then it evaluate the increment/decrement condition and again follows from step 2.
5. When the condition expression becomes false, it exits the loop.
Example:
The below program prints first 10 numbers using for loop:

#include <stdio.h>

void main()
{

    for (int i=1;i<=10;i++){
        printf("My number is %d \n",i);
    }

}

Output:
My number is 1                                                                                                                                                                   
My number is 2                                                                                                                                                                   
My number is 3                                                                                                                                                                   
My number is 4                                                                                                                                                                   
My number is 5                                                                                                                                                                   
My number is 6                                                                                                                                                                   
My number is 7                                                                                                                                                                   
My number is 8                                                                                                                                                                   
My number is 9                                                                                                                                                                   
My number is 10

2. While loop:
  • While loop is considered as entry control loop. 
  • The statements inside the loop are repeatedly executed till the condition is true.
Syntax:
variable initialization;
while(condition)
{
    statements;
    variable increment or decrement;

}

The while loop is executed as follows:
1. It first evaluates the variable initialization (e.g int i= 1;).
2. Checks if the condition(e.g while(i <= 10)) is either true or false. If it is false get out of the loop.
3. If it is true the body of the loop is executed. Variable increment or decrement ( i++ or i-- or i = i + 2 )
Example:
The below prints first 10 numbers using a while loop:

#include <stdio.h>

void main()
{
int i;
    while(i<=10)
        printf("My number is %d \n",i);
    }

}

Output:
My number is 1                                                                                                                                                                   
My number is 2                                                                                                                                                                   
My number is 3                                                                                                                                                                   
My number is 4                                                                                                                                                                   
My number is 5                                                                                                                                                                   
My number is 6                                                                                                                                                                   
My number is 7                                                                                                                                                                   
My number is 8                                                                                                                                                                   
My number is 9                                                                                                                                                                   
My number is 10

3. do while loop:
  • The do while loop is considered as exit control loop. 
  • At first the loop is executed and then it is tested for a condition. 
  • The statements inside the loop is executed at least once.
Syntax:
intialize the variable;
do
{
statements;
increment or decrement the value;
}
while(condition)

The do.. while loop works as follows:
1. It first evaluates the variable initialization (e.g int i= 1;).
2. The body of the loop is executed first. Variable increment or decrement ( i++ or i-- or i = i + 2 )
3. Checks if the condition(e.g while(i <= 10)) is either true or false. If it is false get out of the loop.
4. If it is true get into the loop and execute the statements.

Example:
The below program prints first 10 numbers using a do while loop:

#include <stdio.h>

void main()
{
int i=1;
do
{
     printf("My number is %d \n",i);
        i++;
}
    while(i<=10);
}

Output:
My number is 1                                                                                                                                                                   
My number is 2                                                                                                                                                                   
My number is 3                                                                                                                                                                   
My number is 4                                                                                                                                                                   
My number is 5                                                                                                                                                                   
My number is 6                                                                                                                                                                   
My number is 7                                                                                                                                                                   
My number is 8                                                                                                                                                                   
My number is 9                                                                                                                                                                   
My number is 10 

Input/Output functions in C:
The input/output functions in C are classified into two categories:
1. Console Input/Output Functions – These functions receive input from keyboard and write them on the Monitor.
2. File Input/Output Functions – These functions receives input from a file and writes output to the file.

1. Console Input/Output Functions:
The console input/output functions are classified into:
(i)Formatted Input/Output Functions. Example: printf(), scanf()
(ii)Unformatted Input/Output Functions. Example: puts(), gets()
To use these functions we must begin each C program with a pre-processor directive to include these standard library functions.
This can be done with a line entry - #include <stdio.h>.

printf() and scanf() functions:
  • The scanf() and printf() are used to get input from the user and print to the user output device.
  • They provide the flexibility to receive the input in some fixed format and to give the output in desired format.
  • Format string informs the scanf() function, what type of input to expect and in printf() it is used for what type of output to expect.
Format StringMeaning
%dScan or print an integer as signed decimal number
%fScan or print a floating point number
%cTo scan or print a character
%sTo scan or print a character string. The scanning ends at whitespace.
Syntax:
printf(<control string>, arg1, arg2, . . . , argn);
scanf(<control string>, &address1, &address2, . . . , &addressn);
Example:
#include<stdio.h>

void main()
{
   char name[20];
    
    printf("Please enter your name");
    
    scanf("%s",name);
    
    printf( "\nYou name is : %s", name);

}

puts() and gets() functions:
  • gets() is used to accept the input in the form of string along with the white spaces.
  • puts() is used to print the output string.
Example:

#include <stdio.h>

void main()
{
    char name[71]; //String variable declaration
    printf("\nEnter your Name: ");
    gets(name);
    puts(name);
}
2. File Input/Output functions:
C provides many functions to work with files some basic functions are listed below.
FunctionDescription
fopen()Create a new file or open a existing file
fclose()Closes a file
fgets()Reads a set of data from a file
fputs()Writes a set of data to a file
fgetc()Reads a character from a file
fputc()Writes a character to a file
A file can be created or opened in the following below modes.
Mode Description
r Opens an existing text file for reading.
w Opens a text file for writing. If it does not exist, then a new file is created. 
a Opens a text file for writing in appending mode. If it does not exist, then a new file is created.
r+ Opens a text file for both reading and writing.
w+ Opens a text file for both reading and writing. It first truncates the file to zero length if it exists, otherwise creates a file if it does not exist.
a+ Opens a text file for both reading and writing. It creates the file if it does not exist. The reading will start from the beginning but writing can only be appended.
When working with files we need to declare a pointer of type file. Ex: FILE *ptr_name;
Reading content in a file:
Program:

Output:

Writing to a file:
Program:

Output:

Graphics in C:
Program:

Output:
Programs:
Program for finding "First non-repeated character in given string".

Output:

Program for finding "Digit Identification if string have any numbers".

Output:

Program to sum a number in given string.

Output:

Router Installation

Router Configuration:
  • Connect to the WiFi router.
  • Find out the default gateway of the router by executing ipconfig/all command in the command prompt.

  • This is the address of the router and using this we can get the web interface to configure the router.
  • Open the browser, enter the default gateway in the address bar and hit enter.

  • Enter the login credentials by default both username and password are same as admin.
  • It differs from manufacturer to manufacturer.

Setup WiFi name and password:
  • All the setup steps below differ for different routers.
  • This steps are for Technicolor router.
  • Go to Wireless tab and click on Primary Network and follow the below steps.


Setup Global IP, DNS Server, Gateway:
  • Go to Network tab and click on WAN.
  • Generally WAN Connection Type is DHCP (Dynamic Host Configuration Protocol) i.e IP is assigned dynamically.
  • We can also assign statically as below.

  • Fill the fields and click on Apply.

DHCP Configuration:
  • To setup IP pool, lease time go to Network tab and click on LAN and follow the below step.

  • To find out what all leases are active at the moment, go to Network tab and click on Computers.

  • After connecting two mobiles the leases are as below.

Printer Installation

Printer Installation using USB:
  • Connect the printer to the computer using USB cable.
  • Windows will automatically detect the printer.


  • To download printer drivers open browser and search for drivers.





  • Double click on the driver file to install the driver.


  • Follow the below steps to install the driver.





  • The driver is now installed on the computer. So the printer installation is now completed.

  • Click on Manage and print a test page.


Sharing a Printer:
  • Open Control Panel and then click on Devices and Printers.

  • Select the printer we want to share and right click on the printer.

  • A window will appear as below. Click on Sharing tab and follow the below steps.


  • The printer is shared successfully.
Sharing a folder:
  • To share a folder right click on the folder and then click on Properties.

  • A window will  appear as below. In the Sharing tab click on Advanced Sharing and follow the below steps.







  • The folder is shared successfully.
  • To find the printer and the folder. On the other computer in the same network. Open file explorer and follow the syntax: \\ComputerName and hit enter.
  • The ComputerName is the name of the computer to which the printer is connected.