0% found this document useful (0 votes)
4 views45 pages

Microsoft

The document provides an overview of the .NET Framework and C# fundamentals, detailing its components like the Common Language Runtime (CLR) and Framework Class Library (FCL). It covers C# basics, including data types, operators, conditional statements, and object-oriented programming concepts. Additionally, it introduces ASP.NET, its components, and web forms, along with rich controls, validation controls, and file handling features.

Uploaded by

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

Microsoft

The document provides an overview of the .NET Framework and C# fundamentals, detailing its components like the Common Language Runtime (CLR) and Framework Class Library (FCL). It covers C# basics, including data types, operators, conditional statements, and object-oriented programming concepts. Additionally, it introduces ASP.NET, its components, and web forms, along with rich controls, validation controls, and file handling features.

Uploaded by

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

Unit 1 – Overview of .

NET Framework and C# Fundamentals

1. Overview of .NET Framework

The .NET Framework is a software development platform developed by


Microsoft for building Windows applications, web applications, and
services.

It provides:

 A runtime environment

 Large library support

 Language interoperability

 Security and memory management

Main components:

1. Common Language Runtime (CLR)

2. Framework Class Library (FCL)

2. Common Language Runtime (CLR)

The CLR is the execution engine of the .NET Framework.

It manages the execution of .NET programs.

Functions of CLR

 Memory management

 Garbage collection

 Exception handling

 Security

 Thread management

 Code execution

Working Process

Source Code → Compiler → Intermediate Language (IL) → CLR → Machine


Code

Explanation

1. C# code is compiled into IL code.

2. CLR converts IL into machine language using JIT Compiler.


3. Program executes in the system.

Advantages

 Platform independence

 Automatic memory management

 Better security

 Easy debugging

3. Framework Class Library (FCL)

The FCL is a collection of reusable classes, interfaces, and functions.

It provides ready-made code for:

 File handling

 Database access

 Networking

 GUI applications

 Collections

 String manipulation

Examples

System
[Link]
[Link]
[Link]

Example Program

using System;

class Program
{
static void Main()
{
[Link]("Hello .NET");
}
}

4. C# Fundamentals
Primitive Types and Variables

Primitive data types are basic built-in types in C#.

Data Exampl
Size
Type e

4
int 10
bytes

4
float 10.5f
bytes

8
double 25.67
bytes

2
char 'A'
bytes

bool 1 bit true

string varies "Hello"

Variable Declaration

int age = 20;


float mark = 85.5f;
char grade = 'A';
bool result = true;

5. Operators in C#

Operators are symbols used to perform operations.

Types of Operators

Arithmetic Operators

+ - * / %

Example:

int a = 10, b = 5;
[Link](a + b);

Relational Operators

== != > < >= <=

Logical Operators
&& || !

Assignment Operators

= += -= *= /=

6. Conditional Statements

Conditional statements are used for decision making.

if Statement

int age = 18;

if(age >= 18)


{
[Link]("Eligible");
}

if-else Statement

int num = 5;

if(num % 2 == 0)
{
[Link]("Even");
}
else
{
[Link]("Odd");
}

switch Statement

int day = 2;

switch(day)
{
case 1:
[Link]("Monday");
break;

case 2:
[Link]("Tuesday");
break;
}
7. Looping Statements

Loops are used to repeat statements.

for Loop

for(int i = 1; i <= 5; i++)


{
[Link](i);
}

while Loop

int i = 1;

while(i <= 5)
{
[Link](i);
i++;
}

do-while Loop

int i = 1;

do
{
[Link](i);
i++;
}
while(i <= 5);

foreach Loop

int[] arr = {1,2,3};

foreach(int x in arr)
{
[Link](x);
}

8. Creating and Using Objects

C# is an Object-Oriented Programming language.

Objects are created from classes.


Class and Object Example

using System;

class Student
{
public string name;

public void Display()


{
[Link](name);
}
}

class Program
{
static void Main()
{
Student s = new Student();

[Link] = "Raja";
[Link]();
}
}

Explanation

 Student → Class

 s → Object

 new → Creates object

9. Arrays

Arrays store multiple values of the same type.

Array Declaration

int[] num = {10,20,30,40};

Accessing Array Elements

[Link](num[0]);

Array Example
using System;

class Program
{
static void Main()
{
int[] marks = {80,90,70};

for(int i = 0; i < [Link]; i++)


{
[Link](marks[i]);
}
}
}

10. String Operations

Strings are sequences of characters.

String Declaration

string name = "Raja";

Common String Operations

Concatenation

string a = "Hello";
string b = "World";

[Link](a + " " + b);

Length

string txt = "Welcome";

[Link]([Link]);

Uppercase and Lowercase

[Link]([Link]());
[Link]([Link]());

Substring

string str = "Programming";

[Link]([Link](0,4));
Compare Strings

string s1 = "abc";
string s2 = "abc";

[Link](s1 == s2);

Important Short Notes

CLR

 Execution engine of .NET

 Converts IL to machine code

 Provides garbage collection

FCL

 Collection of reusable classes

 Helps in rapid development

C#

 Object-oriented language

 Developed by Microsoft

 Runs under CLR

Unit 2 – [Link] Basics and Web Forms

1. Introduction to [Link]

[Link] is a web application framework developed by Microsoft for


building:

 Dynamic web pages

 Web applications
 Web services

It works on the .NET Framework.

Features of [Link]

 Server-side technology

 Code reusability

 Security support

 Easy database connectivity

 Fast development

Types of [Link] Applications

1. Web Forms

2. MVC

3. Web API

2. IDE for [Link]

An IDE (Integrated Development Environment) is software used to


write, compile, and execute programs.

IDE Used

Visual Studio

It is the official IDE for [Link] development.

Features of Visual Studio

 Code editor

 Debugging tools

 Drag-and-drop controls

 IntelliSense

 Project management

3. Languages Supported in [Link]

[Link] supports multiple .NET languages.

Common Languages
 C#

 [Link]

 J#

 F#

Example in C#

[Link]("Hello [Link]");

4. Components of [Link]

[Link] contains several important components.

Main Components

1. CLR (Common Language Runtime)

Executes .NET programs.

2. FCL (Framework Class Library)

Provides reusable classes.

3. [Link] Engine

Processes web pages.

4. IIS (Internet Information Services)

Web server used to run [Link] applications.

5. Web Forms

Used to create web pages.

5. Working with Web Forms

A Web Form is a page in [Link] used to create dynamic websites.

Extension:

.aspx

Structure of Web Form

<%@ Page Language="C#" %>

<html>
<body>
<form runat="server">
[Link] Web Form
</form>
</body>
</html>

Important Parts

Part Description

Defines
Page Directive
language

HTML Page structure

form Server-side
runat="server" form

6. Web Form Standard Controls

[Link] provides server controls to interact with users.

Common Standard Controls

Control Purpose

Label Display text

TextBox Input text

Perform
Button
action

CheckBox Select option

RadioButto Single
n selection

HyperLink Create link

7. Label Control

Used to display text.

Example

<asp:Label ID="Label1" runat="server"


Text="Welcome"></asp:Label>
Important Properties

Propert Descripti
y on

Displays
Text
text

ForeColo
Text color
r

Font Font style

8. TextBox Control

Used to receive input from users.

Example

<asp:TextBox ID="txtName"
runat="server"></asp:TextBox>

Properties

Propert
Description
y

Text Gets entered text

MaxLengt Maximum
h characters

TextMode Password/Multiline

Event

Event Description

TextChang Occurs when text


ed changes

9. Button Control

Used to perform actions.

Example

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

Button Click Event

protected void Button1_Click(object sender, EventArgs e)


{
[Link]("Button Clicked");
}

Properties

Proper
Description
ty

Text Button caption

Enable/disable
Enabled
button

Event

Even
Description
t

Occurs when button


Click
clicked

10. HTML Controls in [Link]

[Link] also supports normal HTML controls.

Example

<input type="text" runat="server" />

Common HTML Controls

Control Example

Text
input type="text"
Field

input
Button
type="button"

Checkbo input
x type="checkbox"

Difference Between HTML and [Link] Controls


[Link]
HTML Controls
Controls

Client-side Server-side

Rich
Limited features
functionality

No automatic Supports
events events

11. List Controls

List controls display multiple items.

Types of List Controls

 DropDownList

 ListBox

 CheckBoxList

 RadioButtonList

 BulletedList

12. DropDownList Control

Used to select one item from list.

Example

<asp:DropDownList ID="DropDownList1"
runat="server">

<asp:ListItem>India</asp:ListItem>
<asp:ListItem>USA</asp:ListItem>

</asp:DropDownList>

Properties

Property Description

Items Collection of items


Property Description

SelectedInd Selected item


ex position

SelectedVal
Selected value
ue

Event

Event Description

SelectedIndexChan Occurs when selection


ged changes

13. CheckBoxList Control

Allows multiple selections.

Example

<asp:CheckBoxList ID="CheckBoxList1"
runat="server">

<asp:ListItem>Cricket</asp:ListItem>
<asp:ListItem>Football</asp:ListItem>

</asp:CheckBoxList>

14. RadioButtonList Control

Allows only one selection.

Example

<asp:RadioButtonList ID="RadioButtonList1"
runat="server">

<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>

</asp:RadioButtonList>

15. Important Events in [Link] Controls


Control Event

Button Click

TextBox TextChanged

DropDownLi SelectedIndexChan
st ged

CheckBox CheckedChanged

16. Complete Example Program

ASPX Page

<%@ Page Language="C#" %>

<script runat="server">

protected void Button1_Click(object sender, EventArgs e)


{
[Link] = "Welcome " + [Link];
}

</script>

<html>
<body>

<form runat="server">

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

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

<br><br>

<asp:Label ID="Label1"
runat="server"></asp:Label>

</form>
</body>
</html>

Important Short Notes

[Link]

 Web application framework

 Developed by Microsoft

 Uses .NET Framework

Web Forms

 [Link] page

 Extension is .aspx

Standard Controls

 Label

 TextBox

 Button

List Controls

 DropDownList

 CheckBoxList

 RadioButtonList

Unit 3 – Rich Controls, Validation Controls and File Handling in


[Link]

1. Rich Controls in [Link]


Rich controls are advanced [Link] server controls that provide enhanced
features and better user interaction.

Examples of Rich Controls

 Calendar

 AdRotator

 FileUpload

 MultiView

 Wizard

2. Calendar Control

Used to display and select dates.

Example

<asp:Calendar ID="Calendar1"
runat="server"></asp:Calendar>

Important Properties

Property Description

SelectedDat
Gets selected date
e

TodayDaySt Style for current


yle day

Displays current
VisibleDate
month

Events

Event Description

SelectionChang Occurs when date


ed selected

Occurs when day


DayRender
rendered

Example Event

protected void Calendar1_SelectionChanged(


object sender, EventArgs e)
{
[Link]([Link]);
}

3. AdRotator Control

Displays advertisements one by one.

Example

<asp:AdRotator ID="AdRotator1"
runat="server"
AdvertisementFile="[Link]">
</asp:AdRotator>

Properties

Descriptio
Property
n

AdvertisementF XML file


ile path

Target
Target
window

KeywordFilter Filters ads

4. FileUpload Control

Used to upload files from client to server.

Example

<asp:FileUpload ID="FileUpload1"
runat="server" />

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

Upload Code

protected void Button1_Click(object sender, EventArgs e)


{
if([Link])
{
[Link](
[Link]("files/")
+ [Link]);

[Link]("File Uploaded");
}
}

Properties

Propert
Description
y

Gets uploaded file


FileName
name

HasFile Checks file selected

PostedFil
Uploaded file object
e

5. Validation Controls

Validation controls are used to validate user input.

Types of Validation Controls

Validation Control Purpose

RequiredFieldValidator Mandatory field

RangeValidator Value within range

CompareValidator Compare values

RegularExpressionValid
Pattern validation
ator

User-defined
CustomValidator
validation

ValidationSummary Displays all errors

6. RequiredFieldValidator

Checks whether input field is empty.


Example

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

<asp:RequiredFieldValidator
ID="RequiredFieldValidator1"
runat="server"
ControlToValidate="TextBox1"
ErrorMessage="Field Required">
</asp:RequiredFieldValidator>

Properties

Descriptio
Property
n

ControlToValida Control
te name

ErrorMessage Error text

ForeColor Error color

7. RangeValidator

Checks value within range.

Example

<asp:RangeValidator
ID="RangeValidator1"
runat="server"
ControlToValidate="TextBox1"
MinimumValue="1"
MaximumValue="100"
Type="Integer"
ErrorMessage="Enter value 1 to 100">
</asp:RangeValidator>

8. CompareValidator

Compares two values.

Example
<asp:CompareValidator
ID="CompareValidator1"
runat="server"
ControlToValidate="TextBox2"
ControlToCompare="TextBox1"
ErrorMessage="Passwords do not match">
</asp:CompareValidator>

9. RegularExpressionValidator

Validates using pattern.

Example for Email Validation

<asp:RegularExpressionValidator
ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox1"
ValidationExpression="\w+@\w+\.\w+"
ErrorMessage="Invalid Email">
</asp:RegularExpressionValidator>

10. ValidationSummary

Displays all validation errors together.

Example

<asp:ValidationSummary
ID="ValidationSummary1"
runat="server" />

11. File Stream Classes

File stream classes are used to read and write files.

Namespace:

using [Link];

Important Classes

Class Purpose

FileStream Read/write
Class Purpose

files

StreamRead
Read text files
er

StreamWrite
Write text files
r

BinaryReade Read binary


r files

Write binary
BinaryWriter
files

12. FileStream Class

Used for file operations.

Syntax

FileStream fs =
new FileStream("[Link]",
[Link]);

13. File Modes

Defines how file should open.

Types of File Modes

FileMode Description

Create Creates new file

Opens existing
Open
file

Append Adds data at end

Creates new file


CreateNew
only

OpenOrCrea Opens or creates


te file
14. File Share

Defines file sharing permissions.

Types of FileShare

FileShar Descripti
e on

None No sharing

Allows
Read
read

Allows
Write
write

ReadWrit Allows
e both

15. Reading from Files

Using StreamReader

using System;
using [Link];

class Program
{
static void Main()
{
StreamReader sr =
new StreamReader("[Link]");

string text = [Link]();

[Link](text);

[Link]();
}
}

16. Writing to Files

Using StreamWriter
using System;
using [Link];

class Program
{
static void Main()
{
StreamWriter sw =
new StreamWriter("[Link]");

[Link]("Hello");

[Link]();
}
}

17. Creating Files

Example

[Link]("[Link]");

18. Moving Files

Example

[Link]("[Link]",
"D:\\[Link]");

19. Copying Files

Example

[Link]("[Link]",
"[Link]");

20. Deleting Files

Example

[Link]("[Link]");
21. File Uploading in [Link]

File uploading allows users to upload documents, images, etc.

Steps

1. Use FileUpload control

2. Select file

3. Save file on server

Complete Example

ASPX Page

<asp:FileUpload ID="FileUpload1"
runat="server" />

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

C# Code

protected void Button1_Click(


object sender, EventArgs e)
{
if([Link])
{
string path =
[Link]("Uploads/")
+ [Link];

[Link](path);

[Link]("Uploaded Successfully");
}
}
Unit 4 – [Link] and Data Binding

1. Overview of [Link]

[Link] (ActiveX Data Objects .NET) is a data access technology in


the .NET Framework used to connect applications with databases.

It helps to:

 Connect databases

 Read data

 Insert, update, delete records

 Handle disconnected data

Namespace:

using [Link];
using [Link];

2. Features of [Link]

 Fast data access

 XML support

 Disconnected architecture

 Easy database connectivity

 Supports multiple databases

3. Architecture of [Link]

[Link] contains two main parts:

1. Data Provider

Used to connect and interact with database.

2. DataSet

Stores data temporarily in memory.


4. Components of [Link]

Compone
Purpose
nt

Connection Connects database

Executes SQL
Command
queries

DataReade
Reads data
r

DataAdapt
Transfers data
er

Stores data in
DataSet
memory

5. Database Connection

A connection is used to establish communication between application and


database.

SqlConnection Class

Used to connect SQL Server database.

Syntax

SqlConnection con =
new SqlConnection(
"Data Source=SERVER;
Initial Catalog=StudentDB;
Integrated Security=True");

6. Opening and Closing Connection

Example

using System;
using [Link];

class Program
{
static void Main()
{
SqlConnection con =
new SqlConnection(
"Data Source=.;Initial Catalog=StudentDB;Integrated
Security=True");

[Link]();

[Link]("Connected");

[Link]();
}
}

7. Command Object

The Command object is used to execute SQL queries.

Types of Commands

 SELECT

 INSERT

 UPDATE

 DELETE

SqlCommand Syntax

SqlCommand cmd =
new SqlCommand(query, con);

8. Insert Record Example

SqlConnection con =
new SqlConnection(
"Data Source=.;Initial Catalog=StudentDB;Integrated Security=True");

[Link]();

string query =
"INSERT INTO Student VALUES(1,'Raja')";

SqlCommand cmd =
new SqlCommand(query, con);
[Link]();

[Link]();

Execute Methods

Method Purpose

ExecuteNonQuer INSERT, UPDATE,


y() DELETE

ExecuteReader() SELECT query

ExecuteScalar() Single value

9. DataReader

DataReader is used to read data row by row from database.

It is:

 Fast

 Forward only

 Read only

SqlDataReader Example

SqlConnection con =
new SqlConnection(
"Data Source=.;Initial Catalog=StudentDB;Integrated Security=True");

[Link]();

SqlCommand cmd =
new SqlCommand(
"SELECT * FROM Student", con);

SqlDataReader dr =
[Link]();

while([Link]())
{
[Link](dr[0]);
[Link](dr[1]);
}
[Link]();

10. DataAdapter

DataAdapter acts as bridge between database and DataSet.

It:

 Retrieves data

 Updates database

Example

SqlDataAdapter da =
new SqlDataAdapter(
"SELECT * FROM Student", con);

Important Methods

Metho
Purpose
d

Fill() Fills DataSet

Update Updates
() database

11. DataSet

A DataSet stores data temporarily in memory.

Features:

 Disconnected data access

 Stores multiple tables

 XML support

Example

DataSet ds = new DataSet();

SqlDataAdapter da =
new SqlDataAdapter(
"SELECT * FROM Student", con);
[Link](ds, "Student");

12. Displaying Data from DataSet

foreach(DataRow row in
[Link]["Student"].Rows)
{
[Link](row["Name"]);
}

13. Data Controls in [Link]

Data controls are used to display database data in web pages.

Common Data Controls

Control Purpose

GridView Displays table data

DetailsVie Shows single


w record

Custom record
FormView
display

Repeater Repeated data

DataList Formatted list

14. GridView Control

Displays records in tabular format.

Example

<asp:GridView ID="GridView1"
runat="server">
</asp:GridView>

Properties of GridView

Property Description

DataSource Data source


Property Description

AutoGenerateColu Automatic
mns columns

AllowPaging Enables paging

AllowSorting Enables sorting

15. Binding Data to GridView

ASPX Code

<asp:GridView ID="GridView1"
runat="server">
</asp:GridView>

C# Code

SqlConnection con =
new SqlConnection(
"Data Source=.;Initial Catalog=StudentDB;Integrated Security=True");

SqlDataAdapter da =
new SqlDataAdapter(
"SELECT * FROM Student", con);

DataSet ds = new DataSet();

[Link](ds);

[Link] = ds;

[Link]();

16. DetailsView Control

Displays one record at a time.

Example

<asp:DetailsView ID="DetailsView1"
runat="server">
</asp:DetailsView>
17. Repeater Control

Displays repeated custom formatted data.

Example

<asp:Repeater ID="Repeater1"
runat="server">
<ItemTemplate>
<%# Eval("Name") %>
</ItemTemplate>
</asp:Repeater>

18. Data Binding

Data Binding is the process of connecting controls with database data.

Types of Data Binding

Type Description

Simple
Single value
Binding

Complex Multiple
Binding records

19. DataBind() Method

Used to bind data with controls.

Syntax

[Link]();

20. Complete Example of Data Binding

ASPX Page

<asp:GridView ID="GridView1"
runat="server">
</asp:GridView>

C# Code

using System;
using [Link];
using [Link];

public partial class Default :


[Link]
{
protected void Page_Load(
object sender, EventArgs e)
{
SqlConnection con =
new SqlConnection(
"Data Source=.;Initial Catalog=StudentDB;Integrated
Security=True");

SqlDataAdapter da =
new SqlDataAdapter(
"SELECT * FROM Student", con);

DataSet ds =
new DataSet();

[Link](ds);

[Link] = ds;

[Link]();
}
}
Unit 5 – GridView Operations, XML Classes, Security and Web
Application

1. GridView Control in [Link]

The GridView control is used to display database records in tabular


format.

It supports:

 Editing

 Deleting

 Sorting

 Paging

Basic GridView Example

<asp:GridView ID="GridView1"
runat="server">
</asp:GridView>

2. Editing in GridView

Editing allows users to modify records.

Properties Required

Property Purpose

AutoGenerateEditBut Adds edit


ton button

OnRowEditing Edit event

OnRowUpdating Update event

3. GridView Editing Example

ASPX Page

<asp:GridView ID="GridView1"
runat="server"
AutoGenerateEditButton="True"
OnRowEditing="GridView1_RowEditing"
OnRowUpdating="GridView1_RowUpdating">
</asp:GridView>
C# Code

protected void GridView1_RowEditing(


object sender,
GridViewEditEventArgs e)
{
[Link] =
[Link];

BindGrid();
}

4. Deleting in GridView

Deleting removes records from database.

Required Properties

Property Purpose

AutoGenerateDeleteBu Adds delete


tton button

OnRowDeleting Delete event

5. Delete Example

ASPX Page

<asp:GridView ID="GridView1"
runat="server"
AutoGenerateDeleteButton="True"
OnRowDeleting="GridView1_RowDeleting">
</asp:GridView>

C# Code

protected void GridView1_RowDeleting(


object sender,
GridViewDeleteEventArgs e)
{
[Link]("Row Deleted");
}

6. Sorting in GridView
Sorting arranges data in ascending or descending order.

Properties

Property Description

Enables
AllowSorting
sorting

SortExpressi Column
on sorting

7. Sorting Example

ASPX Code

<asp:GridView ID="GridView1"
runat="server"
AllowSorting="True"
OnSorting="GridView1_Sorting">
</asp:GridView>

C# Code

protected void GridView1_Sorting(


object sender,
GridViewSortEventArgs e)
{
[Link](
"Sorting by " + [Link]);
}

8. Paging in GridView

Paging divides records into multiple pages.

Properties

Property Description

AllowPaging Enables paging

Records per
PageSize
page

OnPageIndexChang Page change


ing event
9. Paging Example

ASPX Page

<asp:GridView ID="GridView1"
runat="server"
AllowPaging="True"
PageSize="5"
OnPageIndexChanging=
"GridView1_PageIndexChanging">
</asp:GridView>

C# Code

protected void GridView1_PageIndexChanging(


object sender,
GridViewPageEventArgs e)
{
[Link] =
[Link];

BindGrid();
}

10. XML in [Link]

XML (Extensible Markup Language) is used to store and transport


data.

Features

 Self-descriptive

 Platform independent

 Easy data sharing

11. XML Classes in .NET

Namespace:

using [Link];

Important XML Classes


Class Purpose

XmlDocume Loads XML


nt document

XmlReader Reads XML

XmlWriter Writes XML

XmlNode Represents node

12. Reading XML File

Example XML File

<Students>
<Student>
<Name>Raja</Name>
</Student>
</Students>

C# Program

XmlDocument doc =
new XmlDocument();

[Link]("[Link]");

XmlNodeList list =
[Link]("Name");

foreach(XmlNode node in list)


{
[Link]([Link]);
}

13. Writing XML File

Example

XmlTextWriter writer =
new XmlTextWriter(
"[Link]", null);

[Link]();
[Link]("Student");

[Link](
"Name", "Raja");

[Link]();

[Link]();

14. Web Form to Manipulate XML Files

[Link] Web Forms can:

 Read XML data

 Write XML data

 Modify XML files

15. Example – Display XML Data in GridView

ASPX Page

<asp:GridView ID="GridView1"
runat="server">
</asp:GridView>

C# Code

DataSet ds = new DataSet();

[Link](
[Link]("[Link]"));

[Link] = ds;

[Link]();

16. Website Security

Website security protects applications from unauthorized access.

Security Features

 Authentication
 Authorization

 Encryption

 Session management

17. Authentication

Authentication verifies user identity.

Example:

 Username and password login

Types of Authentication

Type Description

Windows Uses Windows


Authentication login

Custom login
Forms Authentication
form

Passport Microsoft
Authentication account

18. Forms Authentication Example

[Link]

<authentication mode="Forms">
<forms loginUrl="[Link]">
</forms>
</authentication>

19. Authorization

Authorization decides what resources user can access.

Example

<authorization>
<deny users="?" />
</authorization>

Meaning
 Anonymous users are denied access.

20. Difference Between Authentication and Authorization

Authenticat
Authorization
ion

Gives
Verifies user
permissions

Login process Access control

Checks Checks
identity privileges

21. Creating a Web Application in [Link]

Steps

Step 1

Open Visual Studio

Step 2

Select:

Create New Project

Step 3

Choose:

[Link] Web Application

Step 4

Enter:

 Project name

 Location

Step 5

Add controls to Web Form.

Step 6

Write C# code.

Step 7
Run application using:

Ctrl + F5

22. Simple Web Application Example

ASPX Page

<%@ Page Language="C#" %>

<script runat="server">

protected void Button1_Click(


object sender, EventArgs e)
{
[Link] =
"Welcome " + [Link];
}

</script>

<html>
<body>

<form runat="server">

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

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

<br><br>

<asp:Label ID="Label1"
runat="server"></asp:Label>

</form>

</body>
</html>

You might also like