0% found this document useful (0 votes)
26 views42 pages

Notes1to2units FOR

INTRODUCTION TO .NET FRAMEWORK
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)
26 views42 pages

Notes1to2units FOR

INTRODUCTION TO .NET FRAMEWORK
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

asp.

net programming
NOTES

staff name : [Link]


CLASS : IIII BCA
UNIT NO. OF
DETAILS
HOURS

Overview of .NET framework: Common Language Runtime (CLR),


Framework Class Library- C# Fundamentals: Primitive types and
I Variables – Operators - Conditional statements -Looping statements 15
– Creating and using Objects – Arrays – Stringoperations.

Introduction to [Link] - IDE-Languages supported Components -


Working with Web Forms – Web form standard controls: Properties
II 15
and its events – HTML controls -List Controls: Properties and its
events.
Rich Controls: Properties and its events – validation controls:
Properties and its events– File Stream classes - File Modes – File
III 15
Share – Reading and Writing to files – Creating, Moving, Copying
and Deletingfiles – File uploading.
[Link] Overview – Database Connections – Commands – Data
IV Reader - Data Adapter - Data Sets - Data Controlsand its properties 15
– DataBinding
Grid View control: Deleting, editing, Sorting and Paging. XML
V classes – Web form to manipulate XML files - Website Security - 15
Authentication - Authorization – Creating aWeb application.
[Link] PROGRAMMING

Reference Books
1. Herbert Schildt, The Complete Reference C#.NET, TataMcGraw-Hill,2017.
2. Kogent Learning Solutions, C# 2012 Programming Covers .NET 4.5 Black
Book, Dreamtech pres,2013.
3. Anne Boehm, Joel Murach, Murach‘s C# 2015, Mike Murach& Associates
Inc.2016.
4. DenielleOtey, Michael Otey, [Link]: The Complete reference,
McGrawHill,2008.
5. Matthew MacDonald, Beginning [Link] 4 in C# 2010,APRESS,2010.
Web Resources
1. [Link]
2. [Link]
UNIT I

Overview of .NET framework:

The .NET Framework is a software development framework developed by Microsoft that provides
a runtime environment and a set of libraries and tools for building and running applications on
Windows operating systems. The .NET framework is primarily used on Windows, while .NET Core
(which evolved into just .NET starting from version 5) is cross-platform. The framework supports
multiple programming languages, such as C#, F#, and [Link], and supports a range of application
types, including desktop, web, mobile, cloud, and gaming applications.

Main Components of .NET Framework

 Common Language Runtime(CLR):

o The CLR is the heart of the .NET Framework, acting as a virtual machine that runs
the code and manages various services such as memory management, security,
and thread management. Code that is compiled and executed within the CLR is
called "Managed Code," while code that the CLR does not manage is known as
"Unmanaged Code."

 .NET Framework Class Library (FCL):

o The FCL provides a large set of reusable classes and methods for application
development.
o This includes libraries for input/output operations, networking, data access, UI
controls, and more.

Overall, the .NET Framework is a powerful and versatile development platform that provides a
wide range of tools and libraries for building and running applications on Windows operating
systems.

 .NET is a software framework that is designed and developed by Microsoft. The first
version of the .Net framework was 1.0 which came in the year 2002. In easy words, it is a
virtual machine for compiling and executing programs written in different languages
like C#, [Link], etc.

 It is used to develop Form-based applications, Web-based applications, and Web services.


There is a variety of programming languages available on the .Net platform, [Link]
and C# being the most common ones. It is used to build applications for Windows, phones,
web, etc. It provides a lot of functionalities and also supports industry standards.

 .NET Framework supports more than 60 programming languages of 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.
Common Language Runtime (CLR),

Common Language Runtime (CLR) in C#

The Common Language Runtime (CLR) is a component of the Microsoft .NET Framework that
manages the execution of .NET applications. It is responsible for loading and executing the code
written in various .NET programming languages, including C#, [Link], F#, and others.

When a C# program is compiled, the resulting executable code is in an intermediate language called
Common Intermediate Language (CIL) or Microsoft Intermediate Language (MSIL). This code is not
machine-specific, and it can run on any platform that has the CLR installed. When the CIL code is
executed, the CLR compiles it into machine code that can be executed by the processor.

Working of CLR

1. Compilation and Execution:

 When we write a C# program, it gets compiled into Intermediate Language (IL) code, which
is platform-independent.

 The CLR then uses a Just-In-Time (JIT) compiler to convert the IL code into machine-specific
code while the program runs.

2. Services Provided by CLR:

 CLR handles automatic memory management through Garbage Collection, preventing


memory leaks.

 It ensures that data types are used correctly and safely.

 The CLR checks the IL code for security risks before running it.

3. Cross-Language Integration:

CLR allows code from different .NET languages (C#, [Link], F#) to work together seamlessly through
the Common Type System (CTS).

Key Components of CLR

As the word specify, Common means CLR provides a common runtime or execution environment as
there are more than 60 .NET programming languages.

Framework Class Library

.NET Framework Class Library (FCL)


The Framework Class Library or FCL provides the system functionality in the .NET Framework as it
has various classes, data types, interfaces, etc. to perform multiple functions and build different
types of applications such as desktop applications, web applications, mobile applications, etc. The
Framework Class Library is integrated with the Common Language Runtime (CLR) of the .NET
framework and is used by all the .NET languages such as C#, F#, Visual Basic .NET, etc.

Categories in the Framework Class Library

The functionality of the Framework Class Library can be broadly divided into three categories
i.e utility features written in .NET, wrappers around the OS functionality and frameworks. These
categories are not rigidly defined and there are many classes that may fit into more than one
category.

.NET Programming Languages

The .NET ecosystem supports various programming languages developed by Microsoft and third-
party contributors. Some of the most widely used languages are:

 C# .NET: A modern, object-oriented language used for a wide range of application types.

 [Link]: A language designed for ease of use, with syntax similar to traditional Basic.

 F# .NET: A functional-first programming language, well-suited for complex algorithms and


data processing.

 C++ .NET: An extension of C++ designed for managed code applications.

 J# .NET: A language that provides .NET compatibility for Java developers.

 IronRuby, IronPython: .NET implementations of the Ruby and Python languages.

 Other Languages: [Link], C Omega, ASML, and more.

Is the .NET Application Platform Dependent or Platform Independent?

By default, .NET applications were designed to be platform-dependent, primarily running on


Windows. But because of Mono (a cross-platform framework), and .NET Core, developers can now
run .NET applications on Linux, macOS, and even mobile platforms.

Mono Framework:

 The Mono framework, developed by Novell (now part of Micro Focus), allows .NET
applications to run across different operating systems.

 Though it is cross-platform, Mono is a paid framework.


C# Fundamentals: Primitive types and Variables

🔹 1. What Are Primitive Types?

Primitive types are the basic data types provided by C# to store simple values.

Type Description Example .NET Type

int Integer (whole number) int x = 10; System.Int32

double Floating-point number double pi = 3.14; [Link]

bool Boolean value (true/false) bool isTrue = true; [Link]

char Single character char letter = 'A'; [Link]

string Sequence of characters string name = "John"; [Link]

float Less precise float number float temp = 2.3f; [Link]

long Long integer long big = 123456L; System.Int64

byte Small integer (0 to 255) byte b = 255; [Link]

decimal High precision float decimal price = 99.99m; [Link]

🔹 2. Declaring Variables

In C#, you declare a variable using the syntax:

csharp

CopyEdit

<type> <variableName> = <value>;

✅ Example:

csharp

CopyEdit

int age = 25;

double salary = 45000.50;

bool isActive = true;


You can also declare without assigning:

csharp

CopyEdit

int number;

number = 10;

🔹 3. Type Inference with var

You can let the compiler infer the type:

csharp

CopyEdit

var score = 100; // Inferred as int

var name = "Alice"; // Inferred as string

⚠️Once assigned, the type of a var variable cannot change.

4. Constants

Constants are values that do not change:

csharp

CopyEdit

const double Pi = 3.14159;

You must assign a value at declaration, and it cannot be changed later.

🔹 5. Nullable Types

Primitive types are non-nullable by default. But you can make them nullable:

csharp

CopyEdit

int? age = null;

bool? isMarried = null;

Useful when dealing with databases or optional values.


🔹 6. Conversions Between Types

You can convert between types:

csharp

CopyEdit

int x = 10;

double y = x; // Implicit

double a = 9.8;

int b = (int)a; // Explicit cast

Use methods like Convert.ToInt32() or [Link]() for strings:

csharp

CopyEdit

string input = "123";

int result = [Link](input);

✅ Summary

 Primitive types are built-in types like int, double, bool.

 Variables hold values and must be declared with a type.

 Use var for type inference.

 Use const for constants.

 Nullable types handle null values.

 Use casting or methods for type conversions.

-Operators

In C#, operators are special symbols or keywords that are used to perform operations on variables
and values. C# supports a wide variety of operators, categorized based on their functionality.
🔹 1. Arithmetic Operators

Used to perform basic mathematical operations:

Operator Description Example

+ Addition a+b

- Subtraction a-b

* Multiplication a*b

/ Division a/b

% Modulus (remainder) a % b

🔹 2. Assignment Operators

Used to assign values to variables:

Operator Description Example

= Assign a=b

+= Add and assign a += b

-= Subtract and assign a -= b

*= Multiply and assign a *= b

/= Divide and assign a /= b

%= Modulus and assign a %= b

🔹 3. Comparison (Relational) Operators

Used to compare two values:

Operator Description Example

== Equal to a == b

!= Not equal to a != b

> Greater than a>b


Operator Description Example

< Less than a<b

>= Greater than or equal to a >= b

<= Less than or equal to a <= b

🔹 4. Logical Operators

Used for logical operations (usually with booleans):

Operator Description Example

&& Logical AND a && b

` `

! Logical NOT !a

🔹 5. Bitwise Operators

Used to perform bit-level operations:

Operator Description Example

& AND a&b

` ` OR

^ XOR a^b

~ NOT ~a

<< Left shift a << 2

>> Right shift a >> 2

🔹 6. Unary Operators

Work with a single operand:


Operator Description Example

+ Unary plus +a

- Unary minus -a

++ Increment a++ or ++a

-- Decrement a-- or --a

🔹 7. Conditional (Ternary) Operator

A shorthand for if-else:

csharp

CopyEdit

condition ? expr1 : expr2;

Example:

csharp

CopyEdit

int result = (a > b) ? a : b;

🔹 8. Null-Coalescing Operators

Used for dealing with null values:

Operator Description Example

?? Returns left-hand if not null a ?? b

??= Assign right-hand if left is null a ??= b

🔹 9. Type Testing and Casting Operators

Operator Description Example

is Type checking obj is string

as Safe casting obj as string


Operator Description Example

typeof Gets type info at runtime typeof(int)

sizeof Gets size of value type sizeof(int)

🔹 10. Other Useful Operators

Operator Description Example

. Member access [Link]

[] Indexer arr[0]

() Method call Method()

=> Lambda expression x => x * x

-Conditional statements

In C#, conditional statements are used to perform different actions based on different conditions.
These are essential for controlling the flow of a program.

🔹 1. if Statement

Executes a block of code if the condition is true.

int number = 10;

if (number > 5)

[Link]("Number is greater than 5");

🔹 2. if-else Statement

Provides an alternative block if the condition is false.

int number = 3;
if (number > 5)

[Link]("Greater than 5");

else

[Link]("Less than or equal to 5");

🔹 3. if-else if-else Ladder

Allows checking multiple conditions.

int number = 0;

if (number > 0)

[Link]("Positive");

else if (number < 0)

[Link]("Negative");

else

[Link]("Zero");

}
🔹 4. switch Statement

Efficient for checking a variable against multiple specific values.

int day = 3;

switch (day)

case 1:

[Link]("Monday");

break;

case 2:

[Link]("Tuesday");

break;

case 3:

[Link]("Wednesday");

break;

default:

[Link]("Other day");

break;

🔸 C# 8.0+ supports switch expressions for cleaner code:

string result = day switch

1 => "Monday",

2 => "Tuesday",

3 => "Wednesday",

_ => "Other day"

};
🔹 5. Ternary Operator (?:)

A compact form of if-else.

int age = 20;

string result = (age >= 18) ? "Adult" : "Minor";

[Link](result); // Output: Adult

🔹 6. Null-Coalescing and Null-Conditional

For checking null values in a safe way.

string name = null;

string displayName = name ?? "Guest"; // If name is null, use "Guest"

Person person = null;

string city = person?.Address?.City; // Won’t throw exception if person or Address is null

Would you like a flowchart, sample program, or exercises using these conditional statements?

-Looping statements

In C#, looping statements are used to execute a block of code repeatedly as long as a specified
condition is true. Here are the main types of loops:

🔹 1. for Loop

Used when the number of iterations is known.

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

[Link]("Iteration: " + i);

🔸 Output:
Iteration: 0

Iteration: 1

Iteration: 2

Iteration: 3

Iteration: 4

🔹 2. while Loop

Executes the block as long as the condition is true. Used when the number of iterations is
unknown.

int i = 0;

while (i < 5)

[Link]("i = " + i);

i++;

🔹 3. do-while Loop

Same as while, but guarantees at least one execution because the condition is checked after the
loop body.

int i = 0;

do

[Link]("i = " + i);

i++;

while (i < 5);


🔹 4. foreach Loop

Used to iterate over a collection or array.

string[] names = { "Alice", "Bob", "Charlie" };

foreach (string name in names)

[Link](name);

🔹 5. Loop Control Statements

Statement Description

break Exits the loop immediately

continue Skips the current iteration and continues

return Exits the loop and the entire method

Example:

for (int i = 0; i < 10; i++)

if (i == 5)

break; // Stops the loop when i = 5

if (i % 2 == 0)

continue; // Skips even numbers

[Link](i); // Only prints odd numbers before 5

}
Would you like a practice problem or real-world example using loops?

– Creating and using Objects

1. Define a Class

A class models a real-world entity. For example, a Person with certain attributes and behaviors:

csharp

CopyEdit

public class Person

// Properties (fields with getters/setters)

public string FirstName { get; set; }

public string LastName { get; set; }

public int Age { get; set; }

// Constructor — initializes new objects

public Person(string firstName, string lastName, int age)

FirstName = firstName;

LastName = lastName;

Age = age;

// Method — behavior of the object

public void Introduce()

[Link]($"Hello, my name is {FirstName} {LastName}, and I'm {Age} years old.");


}

🧠 2. Create Objects (Instantiate)

Use the new keyword to create instances:

csharp

CopyEdit

var person1 = new Person("Alice", "Smith", 30);

var person2 = new Person("Bob", "Johnson", 25);

🎯 3. Use Object Properties and Methods

Access their data and call methods:

csharp

CopyEdit

[Link]([Link]); // Outputs "Alice"

[Link] = 26; // Modify a property

[Link](); // "Hello, my name is Alice Smith…"

[Link](); // "Hello, my name is Bob Johnson…"

⚙️4. Parameterless Constructors and Default Values

You can provide a default constructor:

csharp

CopyEdit

public class Person

public string FirstName { get; set; } = "John";

public string LastName { get; set; } = "Doe";


public int Age { get; set; } = 0;

// Default (parameterless) constructor is auto-generated

Usage:

csharp

CopyEdit

var person3 = new Person(); // Uses default values

[Link]([Link]); // "John"

🔄 5. Example: Simple Car Class

csharp

CopyEdit

public class Car

public string Model { get; }

public int Year { get; private set; }

public Car(string model, int year)

Model = model;

Year = year;

public void Drive()

[Link]($"Driving the {Year} {Model}.");


}

// Usage

var myCar = new Car("Toyota Camry", 2020);

[Link]([Link]); // "Toyota Camry"

[Link](); // "Driving the 2020 Toyota Camry."

🧩 6. Common Object Concepts

Concept Description

Encapsulation Use private fields and public properties to control access.

Inheritance Subclass (DerivedClass) inherits from a base class (BaseClass).

Polymorphism Use virtual methods and override to customize behavior in subclasses.

Interfaces Define contracts (public interface IWorker { void Work(); }) that classes implement.

Static Members static methods/properties belong to the class, not instances.

✅ Summary

1. Define a class with fields, properties, constructors, and methods.

2. Instantiate objects using the new keyword.

3. Interact with the object's properties and methods.

4. Use OOP principles like encapsulation, inheritance, and polymorphism for robust design.

– Stringoperations

In C#, strings are sequences of characters, and the string class provides many built-in
operations for working with them. Below are the most commonly used string operations:
🔹 1. Creating Strings

string name = "Alice";

string greeting = "Hello, " + name;

🔹 2. Concatenation

string first = "Hello";

string second = "World";

string result = first + " " + second; // "Hello World"

You can also use [Link]() or [Link]().

🔹 3. String Interpolation (C# 6.0+)

string name = "Bob";

int age = 30;

string message = $"My name is {name} and I am {age} years old.";

🔹 4. Accessing Characters

string word = "Hello";

char firstLetter = word[0]; // 'H'

🔹 5. Common String Methods

Method Description Example

Length Gets the length "hello".Length → 5

ToUpper() Converts to uppercase "abc".ToUpper() → "ABC"

ToLower() Converts to lowercase "ABC".ToLower() → "abc"

Substring(start, length) Extracts part "hello".Substring(1, 3) → "ell"

Replace(old, new) Replaces text "cat".Replace("c", "b") → "bat"


Method Description Example

Contains(value) Checks if contains "apple".Contains("p") → true

IndexOf(value) Finds index "hello".IndexOf("e") → 1

Trim() Removes whitespace " hi ".Trim() → "hi"

Split(separator) Splits string "a,b,c".Split(',')

StartsWith() / EndsWith() Checks prefix/suffix "[Link]".EndsWith(".txt")

🔹 6. Comparing Strings

string a = "Hello";

string b = "hello";

bool equal = a == b; // false (case-sensitive)

bool equalIgnoreCase = [Link](b, [Link]); // true

🔹 7. String Formatting

string formatted = [Link]("Name: {0}, Age: {1}", "Alice", 25);

// "Name: Alice, Age: 25"

🔹 8. Joining Strings

string[] items = { "one", "two", "three" };

string joined = [Link](", ", items);

// "one, two, three"

🔹 9. Null or Empty Checks

string text = "";


bool isEmpty = [Link](text); // true

bool isBlank = [Link](text); // true

🔹 10. Verbatim Strings (@)

Used to avoid escape sequences in file paths or multiline strings:

string path = @"C:\Users\Documents\[Link]";

string multiline = @"Line 1

Line 2

Line 3";

✅ Summary of Useful String Operations:

string str = " Hello World! ";

str = [Link]();

str = [Link]();

bool hasHello = [Link]("HELLO");

int index = [Link]("WORLD");

string part = [Link](0, 5);

Would you like example programs using string operations like searching, formatting, or
validating input?

UNIT II

Introduction to [Link]
[Link] is a free, cross-platform, open-source web framework developed by Microsoft for building
web applications and services. It provides a robust platform for creating dynamic websites, web
APIs, and other web-related applications, leveraging the power of the .NET ecosystem.

Here's a more detailed look:

What is [Link]?

 Framework for Web Development:

[Link] is a server-side technology that enables developers to build dynamic web applications,
websites, and web services.

 Part of the .NET Ecosystem:

It's a key component of the broader .NET framework, allowing developers to utilize its extensive
libraries and tools for efficient development.

 Cross-Platform:

[Link] Core, a more recent version, is cross-platform, meaning it can run on Windows, macOS, and
Linux.

 Open Source:

[Link] is an open-source framework, meaning its source code is publicly available, and developers
can contribute to its development.

Key Features and Benefits:

 Dynamic Web Pages:

[Link] allows for the creation of interactive, data-driven web pages, enhancing user experience.

 Extensible and Scalable:

The framework is designed to be highly extensible and scalable, making it suitable for building both
small and large-scale applications.

 Integration with .NET:

[Link] seamlessly integrates with the .NET framework, allowing developers to utilize its rich set of
libraries and tools.

 Support for Multiple Languages:

It supports various programming languages like C# and [Link], giving developers flexibility in their
choice of language.

 Security and Maintainability:


[Link] promotes security and maintainability, making it a preferred choice for building enterprise-
level applications.

[Link] Core and MVC:

 [Link] Core:

A significant evolution of [Link], offering cross-platform support and improved performance.

 Model-View-Controller (MVC):

[Link] MVC is a popular architectural pattern for building web applications, separating the
application into distinct components (model, view, and controller).

In essence, [Link] provides a powerful and versatile platform for building a wide range of web-
based solutions, leveraging the advantages of the .NET ecosystem and offering features like cross-
platform compatibility, scalability, and strong security features.

- IDE-Languages support – Arrays

IDE (Integrated Development Environment)

An IDE is a software application that provides tools to help programmers write and manage code
efficiently. It includes:

 Code Editor

 Debugger

 Compiler/Interpreter

 Project Management

 IntelliSense (auto-completion)

✅ Popular IDEs for C# and [Link]:

IDE Platform Key Features

Visual Studio Windows, Mac Full-featured IDE for C#, [Link], Blazor

Visual Studio Code Cross-platform Lightweight, extensible with C# and .NET plugins

JetBrains Rider Cross-platform Fast, powerful C# IDE with great refactoring


Languages Supported by .NET / [Link]

[Link] is built on the .NET platform, which supports multiple programming languages, most
commonly:

Language Use Case

C# Primary language for [Link], general-purpose

[Link] Legacy systems, simple syntax

F# Functional programming

✅ C# is the most recommended for modern [Link] development.

📦 Arrays in C#

An array is a fixed-size collection of elements of the same type.

🔹 Declaring and Initializing an Array:

csharp

CopyEdit

int[] numbers = new int[5]; // Declares an array of 5 integers

numbers[0] = 10;

numbers[1] = 20;

// ... up to numbers[4]

🔹 Inline Initialization:

csharp

CopyEdit

int[] values = { 1, 2, 3, 4, 5 };

🔹 Accessing Elements:

csharp

CopyEdit

[Link](values[2]); // Outputs 3

🔹 Looping through Arrays:


csharp

CopyEdit

foreach (int value in values)

[Link](value);

🔹 Array Properties and Methods:

Property/Method Description

Length Gets the number of elements

[Link](array) Sorts the array

[Link]() Reverses the array

🔹 Multi-dimensional Array:

csharp

CopyEdit

int[,] matrix = new int[2, 3] {

{1, 2, 3},

{4, 5, 6}

};

[Link](matrix[1, 2]); // Outputs 6

✅ Summary

Topic Details

IDE Visual Studio, VS Code, Rider

Languages C#, [Link], F#

Arrays Fixed-size collection in C#


ed Components

-Working with Web Forms

Categories of Standard Web Form Controls

Below are the most commonly used categories with examples:

🔹 1. Label

Displays static text or dynamic values.

aspx

CopyEdit

<asp:Label ID="lblMessage" runat="server" Text="Welcome!"></asp:Label>

🔹 2. TextBox

Accepts user input.

aspx

CopyEdit

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

🔹 3. Button

Triggers actions on click.

aspx

CopyEdit

<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />

🔹 4. LinkButton

Looks like a hyperlink, functions like a button.

aspx

CopyEdit
<asp:LinkButton ID="lnkHelp" runat="server" Text="Help" OnClick="lnkHelp_Click" />

🔹 5. CheckBox

Used for binary options (Yes/No).

aspx

CopyEdit

<asp:CheckBox ID="chkAgree" runat="server" Text="I agree to terms" />

🔹 6. RadioButton

Used for selecting one option from a group.

aspx

CopyEdit

<asp:RadioButton ID="rbMale" runat="server" GroupName="Gender" Text="Male" />

<asp:RadioButton ID="rbFemale" runat="server" GroupName="Gender" Text="Female" />

🔹 7. DropDownList

Creates a dropdown menu.

aspx

CopyEdit

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

<asp:ListItem Text="Select" Value="" />

<asp:ListItem Text="USA" Value="US" />

<asp:ListItem Text="India" Value="IN" />

</asp:DropDownList>

🔹 8. ListBox

Displays a scrollable list of items.


aspx

CopyEdit

<asp:ListBox ID="lstColors" runat="server" SelectionMode="Multiple">

<asp:ListItem>Red</asp:ListItem>

<asp:ListItem>Green</asp:ListItem>

<asp:ListItem>Blue</asp:ListItem>

</asp:ListBox>

🔹 9. HyperLink

Creates a standard clickable link.

aspx

CopyEdit

<asp:HyperLink ID="hlGoogle" runat="server" NavigateUrl="[Link] Text="Go to


Google" />

🔹 10. Image

Displays an image.

aspx

CopyEdit

<asp:Image ID="imgLogo" runat="server" ImageUrl="~/images/[Link]" />

🔹 11. Calendar

Provides a visual calendar control for selecting dates.

aspx

CopyEdit

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


🔹 12. FileUpload

Allows users to upload files to the server.

aspx

CopyEdit

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

🔧 Behind-the-Scenes: Code-Behind (C#)

Example C# handler:

csharp

CopyEdit

protected void btnSubmit_Click(object sender, EventArgs e)

[Link] = "Hello, " + [Link];

📌 Summary Table

Control Purpose

Label Display text

TextBox Get user input

Button Submit form or action

CheckBox Toggle option

RadioButton Choose one from a group

DropDownList Select from dropdown

ListBox Multi-select list

Calendar Select dates

FileUpload Upload files


– Web form standard controls: Properties and its events

Here is a detailed explanation of [Link] Web Form Standard Controls, their commonly used
properties, and important events:

✅ 1. Label

Property Description

Text Text displayed in the label

ForeColor Text color

Font Font style (Bold, Size, etc.)

Event Description

(No major events) Labels are static display controls

aspx

CopyEdit

<asp:Label ID="lblMessage" runat="server" Text="Welcome!"></asp:Label>

✅ 2. TextBox

Property Description

Text User input text

MaxLength Maximum number of characters allowed

TextMode SingleLine, MultiLine, or Password

Enabled Enable/disable user input

Event Description

TextChanged Triggered when text is changed and postback occurs

aspx

CopyEdit
<asp:TextBox ID="txtName" runat="server" TextMode="SingleLine" AutoPostBack="True"
OnTextChanged="txtName_TextChanged"></asp:TextBox>

✅ 3. Button

Property Description

Text Button label text

Enabled True/False (clickable or not)

CausesValidation Triggers validation controls on click

Event Description

Click Occurs when the button is clicked

aspx

CopyEdit

<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />

✅ 4. CheckBox

Property Description

Text Text displayed next to the box

Checked True/False

Event Description

CheckedChanged Fires when the checked state changes

aspx

CopyEdit

<asp:CheckBox ID="chkAgree" runat="server" Text="Agree" AutoPostBack="True"


OnCheckedChanged="chkAgree_CheckedChanged" />

✅ 5. RadioButton
Property Description

Text Label for the button

GroupName Groups buttons together

Checked Whether it's selected

Event Description

CheckedChanged Triggered when selection changes

aspx

CopyEdit

<asp:RadioButton ID="rbMale" runat="server" GroupName="Gender" Text="Male"


AutoPostBack="True" OnCheckedChanged="GenderChanged" />

✅ 6. DropDownList

Property Description

Items Collection of list items

SelectedItem, SelectedValue, SelectedIndex To get selected data

Event Description

SelectedIndexChanged Fires when selection changes

aspx

CopyEdit

<asp:DropDownList ID="ddlCountry" runat="server" AutoPostBack="True"


OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged">

<asp:ListItem Text="Select" Value="" />

<asp:ListItem Text="USA" Value="US" />

</asp:DropDownList>

✅ 7. ListBox
Property Description

SelectionMode Single / Multiple selection

Items List items

Event Description

SelectedIndexChanged Triggered when item selected

aspx

CopyEdit

<asp:ListBox ID="lstFruits" runat="server" SelectionMode="Multiple" AutoPostBack="True"


OnSelectedIndexChanged="lstFruits_SelectedIndexChanged">

<asp:ListItem>Apple</asp:ListItem>

<asp:ListItem>Banana</asp:ListItem>

</asp:ListBox>

✅ 8. Calendar

Property Description

SelectedDate Date selected by the user

VisibleDate Current visible month

Event Description

SelectionChanged Occurs when user picks a date

aspx

CopyEdit

<asp:Calendar ID="calendar" runat="server"


OnSelectionChanged="calendar_SelectionChanged"></asp:Calendar>

✅ 9. FileUpload
Property Description

HasFile Checks if a file is selected

FileName Name of the selected file

PostedFile Full file object including content

| Event | (No specific events) |

aspx

CopyEdit

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

<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" />

✅ Summary Table

Control Key Properties Key Events

Label Text (none)

TextBox Text, MaxLength, TextMode TextChanged

Button Text, Enabled Click

CheckBox Text, Checked CheckedChanged

RadioButton Text, Checked, GroupName CheckedChanged

DropDownList Items, SelectedValue SelectedIndexChanged

ListBox Items, SelectionMode SelectedIndexChanged

Calendar SelectedDate SelectionChanged

FileUpload HasFile, FileName, PostedFile (none)

HTML controls -List Controls: Properties and its events.

HTML List Controls Overview

HTML provides several list controls for displaying lists of options. These are client-side controls
and don’t use the [Link] runat="server" feature unless manually wired to the server.
✅ 1. <select> (Dropdown List & ListBox)

🔹 Basic Dropdown (Single Select):

html

CopyEdit

<select id="ddlFruits">

<option value="apple">Apple</option>

<option value="banana">Banana</option>

</select>

🔹 ListBox (Multiple Select):

html

CopyEdit

<select id="lstColors" multiple size="4">

<option value="red">Red</option>

<option value="green">Green</option>

<option value="blue">Blue</option>

</select>

Properties (HTML attributes):

Attribute Description

id Unique identifier for the element

name Form field name used in submission

multiple Allows multiple selection (ListBox)

size Number of visible rows

value The data/value assigned to each option

disabled Disables the control

selected Pre-selects an item


Attribute Description

⚙️JavaScript Events:

Event Description

onchange Triggered when the selected option changes

onfocus When the control gains focus

onblur When the control loses focus

🔹 Example with Event:

html

CopyEdit

<select id="ddlCountry" onchange="countryChanged()">

<option value="us">USA</option>

<option value="in">India</option>

</select>

<script>

function countryChanged() {

var selected = [Link]("ddlCountry").value;

alert("Selected Country: " + selected);

</script>

✅ 2. <ul> / <ol> (Unordered / Ordered Lists)

These are used for displaying textual lists, not form inputs.

html
CopyEdit

<ul>

<li>HTML</li>

<li>CSS</li>

<li>JavaScript</li>

</ul>

🔹 Properties (HTML attributes):

Attribute Description

type (For <ol>) 1, A, a, I, i

start Starting number for <ol>

id For JavaScript reference

🔹 Events:

Normally, <ul> and <ol> don’t have built-in form events, but you can bind click events to <li>
items:

html

CopyEdit

<ul id="skills">

<li onclick="selectSkill(this)">HTML</li>

<li onclick="selectSkill(this)">CSS</li>

</ul>

<script>

function selectSkill(item) {

alert("You clicked: " + [Link]);

</script>
✅ Summary Table

Control Description Key Properties Key Events

<select> Dropdown/ListBox multiple, size, value onchange, onblur, onfocus

<ul>/<ol> Ordered/unordered list (not input) type, start, id onclick (on <li>)

🧠 TIP ([Link] Integration)

You can access these HTML elements in [Link] with:

csharp

CopyEdit

string value = [Link]["ddlFruits"];

Or if using runat="server":

html

CopyEdit

<select id="ddlFruits" runat="server">

You might also like