0% found this document useful (0 votes)
44 views61 pages

Unit Four

asp

Uploaded by

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

Unit Four

asp

Uploaded by

gunjan Sathawane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 61

Join Our Telegram Community - Aspire2Learn

“We are here to provide you with simplified


notes for BCA and to help you throughout
your BCA journey...
Team, Aspire2Learn”

Join Our Telegram Community - Aspire2Learn


ASP.NET SYLLABUS
UNIT - I :
Introduction To Xml Introduction To Xml, Creating Dtd,Elements And Attributes
Definitions.Xml Schema.Defining Simple And Complex Types.Namespaaces,Schemas
And Validation. Cascading Style Sheets(Css) L And Xml, Anatomy Of A Style,Creating
And Calling Style Sheets For An Xml/Html Document.Layout With Css. Setting Up
Various Properties Of Elements Using Css.Formatting Text With Css,Xml Schemas,
Writing Simple Sheets Using Xslt,Sax And Dom Parsers, Soap Introduction.

UNIT - II :
Introduction To Asp .Net Inroduction To Asp .Net, Types,Object And
Namespaces, Setting Up Asp .Net And Iis,Asp .Net Configuration, Asp .Net
Application,Web Form Fundamentals, Web Controls,Global.Asax Application
File,Responding To Postback Events In Asp .Net.

UNIT - III :
Asp .Net Validations And Rich Controls:Calendar
Control,Adrotator,Advertisement File And Adrotator Class, Server-Side
Validation,Client –Side Validation,Validation Controls,Validated Customer
Form.Stat Management, Tracing,Logging And Error Handling.

UNIT - IV :
Accessing Data With Ado.Net Relational Databases And Sql,Ado .Net Object
Model, Working With Data –Bound Controls, Populating A Datagrid, Datalist
And Repeater, Customizing Dataset And Combining Data Tables,Changing
Database Records Accessing,Updating,Deleting And Creating Records,
Difference Between Ado .Net And Xml,Adding Controls, Data Binding,
Database Connectivity.
Join Our Telegram Community - Aspire2Learn
UNIT FOUR –
1. Describe The Working Of ADO.NET.
S[2024,2019,2018],W[2023].
Ans –
What is ADO.NET –

1. ADO.NET (ActiveX Data Objects for .NET) is a data access


technology in ASP.NET that allows interaction with
databases such as SQL Server, MySQL, Oracle, etc.

2. It enables data retrieval, insertion, deletion, and


updating in both connected and disconnected
environments.

Working of ADO.NET in ASP.NET –

Step 1: Establish Connection -


 Use SqlConnection to connect with the database.

 Connection string specifies database details like server


name, database name, authentication type, etc.

 Example:

Join Our Telegram Community - Aspire2Learn


Step 2: Execute SQL Commands -
 Use SqlCommand to execute SELECT, INSERT, UPDATE,
DELETE queries.

 Example (Retrieving Data):

Step 3: Fetch Data (Connected or Disconnected Mode)

 Example (Connected Mode - Using SqlDataReader):

Join Our Telegram Community - Aspire2Learn


 Example (Disconnected Mode - Using DataSet):

Step 4: Perform CRUD Operations -


 INSERT, UPDATE, DELETE operations can be performed
using SqlCommand.

 Example (Insert Data):

Join Our Telegram Community - Aspire2Learn


Step 5: Close Connection -
 After executing commands, always close the connection
Operation
 User views products
 User adds to cart
 User updates quantity
 User removes item
 Checkout process

Components of ADO.NET –

Component Description

SqlConnection Establishes a connection


with the database.
SqlCommand Executes SQL queries and
stored procedures.
Join Our Telegram Community - Aspire2Learn
SqlDataReader Reads data sequentially from
the database.
SqlDataAdapter Fills the DataSet with data
from the database.
DataSet Stores multiple tables of data
offline.
DataTable Stores a single table of data
in memory.

Example -
Scenario: Online Shopping Website (E-Commerce App)
 Imagine an online shopping website like Amazon where
users can:
 View product details (Retrieve Data)

 Add products to cart (Insert Data)

 Update quantity in cart (Update Data)

 Remove items from cart (Delete Data)

How ADO.NET Works in This Scenario?


Operation ADO.NET Component Used Real-World
Action
User views SqlConnection, SqlCommand, Fetching
products SqlDataReader product
details from
Join Our Telegram Community - Aspire2Learn
the
database to
display on
the website.
User adds SqlCommand.ExecuteNonQuery() Adding a
to cart product to
the
shopping
cart table.
User SqlCommand.ExecuteNonQuery() Updating
updates the quantity
quantity of an item
in the cart.
User SqlCommand.ExecuteNonQuery() Deleting an
removes item from
item the cart.

Checkout SqlDataAdapter, DataSet Storing


process multiple
order
details
temporarily
before
placing the
order.

 Code Example: Retrieving Products (Viewing Items


on Website)

Join Our Telegram Community - Aspire2Learn


 Expected Output (Displayed on Website)

Join Our Telegram Community - Aspire2Learn


2. What Is ADO.NET Connectivity ?. W[2023].
Ans –
ADO.NET Connectivity –

1. ADO.NET (ActiveX Data Objects for .NET) is a data access


technology in ASP.NET that allows communication
between a web application and a database.

2. It helps in retrieving, inserting, updating, and deleting


data from databases such as SQL Server, MySQL, Oracle,
etc.

3. Key Features:

 Uses connection-oriented (SQLConnection) &


disconnected (Dataset) model.

 Supports queries (SELECT, INSERT, UPDATE, DELETE).

 Works with relational and XML databases.

 Ensures efficient data handling in web applications.

Steps for ADO.NET Database Connectivity in ASP.NET

Steps to Connect ASP.NET with SQL Database

Join Our Telegram Community - Aspire2Learn


1. Create a Database & Table –

2. Add Connection String in Web.config –

3. Design ASP.NET Web Form (Default.aspx)

Join Our Telegram Community - Aspire2Learn


4. Write Code in Default.aspx.cs

Join Our Telegram Community - Aspire2Learn


Explanation of Code –

Database Connection:
 SqlConnection establishes a connection to the database.

 SqlCommand executes SQL queries.

Data Retrieval & Binding:


 SqlDataAdapter fetches data and fills a DataTable.

 GridView1.DataSource = dt; binds data to the UI.

 GridView1.DataBind(); displays data in a tabular format.

Expected Output (Web Page Display) –

EmployeeID Name Department Salary

1 John Doe IT 60000

2 Jane Smith HR 50000

3 Michael Lee Finance 55000

3. Differentiate Between ADO.NET And XML. W[2022].

Join Our Telegram Community - Aspire2Learn


Ans -
Feature ADO.NET XML

Purpose Data access and Data


manipulation representation
(databases) and exchange

Data Source Relational Text files,


databases (SQL streams, in-
Server, etc.) memory data

Data Model Relational (tables, Hierarchical


rows, columns) (elements,
attributes)
Primary Use Database Data storage, data
interactions (CRUD transport,
operations) configuration

Data Format Binary (primarily, Text-based


within databases) (human-
readable)
Data Access Provides classes for Provides parsers
database and serializers
connections

Data Focus Data retrieval and Data structure


manipulation and format

Interoperability Limited to database Highly


connections. interoperable
across platforms.
Join Our Telegram Community - Aspire2Learn
Common Objects DataSet, DataTable, XmlDocument,
DataAdapter, XmlReader,
Command, XmlWriter
Connection

Relationship Can Can be used as a


serialize/deserialize data source for
data to XML ADO.NET
------------------------------------------------------------------------------
5. Explain Data Binding In ASP.NET Web Form.
W[2023,2018].
OR
6. What Is Data Bindings ? Explain Its Types. W[2019].
Ans –
What is Data Binding –

1. Data Binding in ASP.NET is the process of connecting UI


controls (like GridView, DropDownList, ListBox) to a
data source (like a database, XML file, or collection).

2. It enables automatic population of UI elements with data.

Types of Data Binding in ASP.NET –

Type Description Example

Join Our Telegram Community - Aspire2Learn


Simple Data Binds a single Binding TextBox
Binding value to a control to a database
(like TextBox, column.
Label).

Complex Data Binds multiple Displaying


Binding values to controls multiple records
(like GridView, in a
DropDownList). GridView.

Example: Data Binding with GridView (Displaying


Product List)

 This example retrieves product details from a database


and binds them to a GridView.

Steps to Implement:
1. Create a Database Table (SQL Server)

Join Our Telegram Community - Aspire2Learn


2. Design ASP.NET Web Form (Default.aspx)

3. Code-Behind (Default.aspx.cs)

Explanation of Code –

Join Our Telegram Community - Aspire2Learn


1. Database Connection:

 Uses SqlConnection to connect to SQL Server.

 SQL Query (SELECT * FROM Products) fetches data.

2. Data Adapter & DataTable:

 SqlDataAdapter fetches data from the database.

 DataTable stores the retrieved data.


Join Our Telegram Community - Aspire2Learn
3. Data Binding:

 GridView1.DataSource = dt; → Assigns data to GridView.

 GridView1.DataBind(); → Renders data on the webpage.

Expected Output (GridView on Web Page) –

ProductID ProductName Price

1 Laptop 50000

2 Mouse 700

3 Keyboard 1200

------------------------------------------------------------------------------
7. Explain Structure Of Connection String For Database
Connectivity. S[2023,2018].
Ans –
1. A Connection String is a string used to establish a
connection between an ASP.NET application and a
database.

Join Our Telegram Community - Aspire2Learn


2. It contains essential parameters like server name,
database name, authentication details, and provider
information.

General Syntax of Connection String -

Components of a Connection String -

Example Connection Strings for Different Databases -

1. SQL Server Authentication (Username & Password)

2. SQL Server (Windows Authentication)

Join Our Telegram Community - Aspire2Learn


3. MySQL Connection -

4. PostgreSQL Connection -

5. Oracle Connection –

8. Explain Database Connectivity In ASP.NET.


S[2019],W[2022,2019].
Join Our Telegram Community - Aspire2Learn
Ans –
1. Database connectivity in ASP.NET is achieved using
ADO.NET, which allows applications to interact with
relational databases such as SQL Server, MySQL, Oracle,
etc.

2. It provides a way to perform CRUD (Create, Read,


Update, Delete) operations on a database.

Steps for Database Connectivity in ASP.NET -


 Establish Connection → Connect to the database using
SqlConnection.

 Execute Queries → Use SqlCommand to run SQL queries.

 Retrieve Data → Use SqlDataReader or DataAdapter.

 Manipulate Data → Use INSERT, UPDATE, DELETE


queries.

 Close Connection → Free up resources.

Components of ADO.NET for Database Connectivity -

Explanation -
 Connects to SQL Server Database using SqlConnection.

 Executes a SELECT Query using SqlCommand.


Join Our Telegram Community - Aspire2Learn
 Fetches data using SqlDataAdapter and binds to
GridView.

Step 1: Add Connection String in Web.config –

Step 2: ASP.NET C# Code (Default.aspx.cs) -

Join Our Telegram Community - Aspire2Learn


Step 3: Add GridView in Default.aspx –

Expected Output –
Join Our Telegram Community - Aspire2Learn
ID Name Department

1 John IT

2 Sarah HR

------------------------------------------------------------------------------
9. Explain Data Grid, Data List And Repeater. S[2024].
OR
10. Explain Data List And Repeater In Detail. W[2023,2017].
Ans –
1. DataGrid Control –

Overview -

 Displays tabular data (rows & columns).

 Supports sorting, paging, and editing.

 Uses BoundField, TemplateField, ButtonField for


customization.

 Best suited for structured data like tables.

Example of DataGrid Control -


Join Our Telegram Community - Aspire2Learn
Code Behind (C#)

Expected Output –

Join Our Telegram Community - Aspire2Learn


ID Name Department Salary

1 John IT 50000

2 Sarah HR 45000

2. DataList Control

Overview
 Displays data in a flexible layout (Grid, List, Horizontal,
Vertical, etc.).

 Uses Template Fields for customization.

 Supports multiple columns.

Example of DataList Control –

Join Our Telegram Community - Aspire2Learn


Expected Output

3. Repeater Control

Overview

 Lightweight & highly customizable (No built-in styles).

 Uses ItemTemplate, HeaderTemplate, FooterTemplate.

Join Our Telegram Community - Aspire2Learn


 Best for custom UI & performance optimization.

Example of Repeater Control -

Expected Output –

Join Our Telegram Community - Aspire2Learn


------------------------------------------------------------------------------
11. Explain A Data Grid Control In Detail. S[2023].
OR
12. Explain Data-Grid Control And Data Handling With
Example. S[2019,2017].
Ans –
Data Grid Control –

1. The DataGrid control in ASP.NET is a server-side control


used to display, edit, update, delete, and sort tabular
data.

2. It allows developers to bind data from a database, XML


file, or collection and render it as a grid-like structure
with rows and columns.

3. Key Features:
o Displays data in a tabular format
Join Our Telegram Community - Aspire2Learn
o Supports sorting, paging, and editing

o Supports auto-generation of columns

o Allows custom styling for better UI

Properties of DataGrid Control -

Property Description

DataSource Binds data from a database,


XML, or collection.
AutoGenerateColumns Automatically creates
columns based on data
source.
HeaderStyle Styles the header row.

ItemStyle Styles the data rows.

AllowSorting Enables sorting.

AllowPaging Enables pagination.

EditItemIndex Identifies the row being


edited.
PageSize Defines the number of
records per page.

Join Our Telegram Community - Aspire2Learn


Example: Displaying Employee Records in DataGrid

Steps to Implement:

Create a SQL Database Table (Employees) –

Design ASP.NET Web Form (Default.aspx)

Join Our Telegram Community - Aspire2Learn


Code-Behind (Default.aspx.cs)

Join Our Telegram Community - Aspire2Learn


Explanation of Code –

Database Connection:
 Establishes a connection using SqlConnection.

 Fetches records using SqlCommand with SELECT *


FROM Employees.

Join Our Telegram Community - Aspire2Learn


Data Binding:
 SqlDataAdapter retrieves data and fills a DataTable.

 DataGrid1.DataSource = dt; binds the table to the


DataGrid.

 DataGrid1.DataBind(); renders the data on the webpage.

Expected Output (DataGrid on Web Page) –

EmployeeID Name Department Salary

1 John Doe IT 60000

2 Jane Smith HR 50000

3 Michael Lee Finance 55000

------------------------------------------------------------------------------
Q.5 – Short Answer Questions
------------------------------------------------------------------------------
1. Explain Data Binding. S[2024,2023].
Ans –
1. Data Binding in ASP.NET is the process of connecting UI
controls (such as GridView, DropDownList, and
ListView) to a data source (like a database, XML file, or
collection) to dynamically display data.
Join Our Telegram Community - Aspire2Learn
Types of Data Binding -
 Simple Data Binding – Binds a single value to controls
like Label, TextBox, and DropDownList.

 Complex Data Binding – Binds a collection of data (like


databases or lists) to controls like GridView, Repeater,
and DataList.

Example of Simple Data Binding –

Example of Complex Data Binding (GridView with SQL


Database) -

Join Our Telegram Community - Aspire2Learn


 Fetches data from a SQL database and binds it to a
GridView.

Key Benefits of Data Binding -


 Reduces Code Complexity – No need for manual data
updates.

 Dynamically Updates UI – Changes in data reflect


automatically.

 Supports Multiple Data Sources – Works with databases,


XML, and collections.

Real-Life Example of Data Binding –

Example: Online Shopping App (Amazon, Flipkart, etc.)

Join Our Telegram Community - Aspire2Learn


 Imagine you are browsing an E-commerce website like
Amazon. When you search for "Mobile Phones," the
website fetches product data from a database and
displays it in a list/grid format.

How Data Binding Works in This Case?


 You search for "Mobile Phones" → A request is sent to
the database.

 The database retrieves product details (name, price,


image, etc.).

 The product details are dynamically bound to UI controls


like GridView, ListView, or Repeater in ASP.NET.

 The webpage automatically updates to show the latest


product details without manual coding for each product.

------------------------------------------------------------------------------
2. Explain Its Services Used In Asp.Net Application.
W[2023,2022,2018].
Ans –
Services Used in ASP.NET Application -
 ASP.NET provides various built-in services to enhance
web applications' performance, security, and
functionality.

Join Our Telegram Community - Aspire2Learn


 Below are some key services used in ASP.NET
applications:

1. Caching Service
 Purpose: Improves performance by storing frequently
accessed data in memory.

 Example:

 Storing database query results to reduce server load.

 Using Cache.Insert() to cache data.

2. Authentication & Authorization Service


 Purpose: Ensures security by verifying user identity &
access control.

Example:
 Forms Authentication (Login system).

 Windows Authentication (Active Directory).

 OAuth (Google, Facebook Login).

3. State Management Service


 Purpose: Maintains user data across web pages.

Types:
Join Our Telegram Community - Aspire2Learn
 Session State: Stores user data per session.

 Application State: Stores global data.

 Cookies: Stores small client-side data.

4. Error Handling & Logging Service


 Purpose: Catches and logs errors for debugging &
monitoring.

Example:
 Using try-catch for exception handling.

 Writing logs using Log4Net or NLog.

5. Email Sending Service (SMTP)


 Purpose: Allows sending emails from ASP.NET
applications.

 Example:

 Sending verification emails using System.Net.Mail.

6. Web API & Web Services


 Purpose: Enables communication between applications
via HTTP.

 Example:
Join Our Telegram Community - Aspire2Learn
 RESTful APIs for data exchange.

 SOAP-based Web Services.


7. Database Connectivity (ADO.NET & Entity Framework)
 Purpose: Connects ASP.NET applications to databases.

 Example:

 Using ADO.NET for SQL queries.

 Using Entity Framework for ORM (Object-Relational


Mapping).
------------------------------------------------------------------------------
3. Explain Error Tracing. W[2023,2017].
Ans –
Error Tracing -
1. Error tracing in ASP.NET is used to track and diagnose
errors in a web application.

2. It helps developers understand what went wrong by


recording error details for debugging and monitoring.

Types of Tracing in ASP.NET


 Page-Level Tracing – Enables tracing for a single page.

 Application-Level Tracing – Enables tracing for the


entire application.
Join Our Telegram Community - Aspire2Learn
Enabling Tracing –

1. Page-Level Tracing (For a Single Page) –

 Add the following directive at the top of your .aspx page:

 This displays a detailed trace report at the bottom of the


page.

2. Application-Level Tracing (For Entire Application) -

 Enable tracing in Web.config:

 This logs traces for multiple requests, viewable at


trace.axd (e.g., http://localhost/trace.axd).

Join Our Telegram Community - Aspire2Learn


Key Trace Information -
 Request & Response Details – Displays execution time,
control tree, and session variables.

 Error Messages – Captures unhandled exceptions.

 Execution Flow – Helps debug performance issues.

Real-World Use Cases -


 Debugging slow pages by analyzing execution time.

 Tracking errors & warnings to improve application


stability.

 Monitoring user requests to optimize performance.

Error tracing helps developers identify & fix issues quickly!


------------------------------------------------------------------------------
4. Write A Note On ‘Soap’. W[2022,2019].
Ans –
1. SOAP (Simple Object Access Protocol) is a protocol used
for exchanging structured information in web services
over a network. It is based on XML messaging and
enables platform-independent communication.

2. Key Features of SOAP:


 Uses XML for request and response messages.

Join Our Telegram Community - Aspire2Learn


 Follows strict message structure (envelope, header,
body).
 Supports security standards like WS-Security.
 Works over multiple protocols (HTTP, SMTP, TCP,
etc.).
 Provides reliable communication in enterprise
applications.

3. Real-World Example:

 Online Banking Web Service: SOAP ensures secure


transactions when retrieving account balances,
processing payments, and verifying users.

SOAP in ASP.NET -
 In ASP.NET, SOAP is used in Web Services (.asmx) to
allow communication between different applications.
ASP.NET provides built-in support for SOAP-based web
services.

How it Works?
 Client sends a SOAP request to the server.
 Server processes the request and sends a SOAP
response.
 Data is exchanged in XML format, ensuring platform
independence.

Join Our Telegram Community - Aspire2Learn


Example of SOAP Web Service in ASP.NET
Step 1: Create an ASP.NET SOAP Web Service –
(CalculatorService.asmx)

Step 2: Client Sends SOAP Request

Join Our Telegram Community - Aspire2Learn


Step 3: Server Sends SOAP Response

Expected Output:
 Client sends 5 + 10, Server returns 15 as response in
SOAP format.

------------------------------------------------------------------------------
5. Write Short Note On ‘Data List Control’. W[2022,2019].
Ans –
Data List Control –

1. The DataList Control in ASP.NET is a data-bound control


used to display data in a customizable list format. It is
more flexible than a GridView because it allows defining
custom layouts using templates.

2. Key Features -
o Supports multiple layouts (grid, vertical, horizontal).

Join Our Telegram Community - Aspire2Learn


o Uses Templates for customization (ItemTemplate,
HeaderTemplate, FooterTemplate).

o Allows paging, sorting, and editing (with extra code).

o Supports data binding with databases like SQL


Server.

Example Code (DataList Example) –

Explanation
 DataList → Binds data from SqlDataSource1 and displays
it.

 ItemTemplate → Defines the structure for each record.

 Eval("ColumnName") → Retrieves values from the


database.
Join Our Telegram Community - Aspire2Learn
Real-World Use Cases -
 Displaying customer lists, product catalogs, employee
records with custom layouts.

 Creating responsive web pages with advanced design


flexibility.
------------------------------------------------------------------------------
6. What Is Validation ? S[2019,2018].
Ans –
Validation -
1. XML Validation is the process of checking whether an
XML document follows a defined structure and rules
using DTD (Document Type Definition) or XSD (XML
Schema Definition).

2. Validation ensures that XML data is correct, consistent,


and error-free before processing.

3. Key Benefits of XML Validation:


 Ensures data accuracy.

 Prevents incorrect data from being processed.

 Helps in error detection before usage.

 Allows data exchange between different systems without


errors.
Join Our Telegram Community - Aspire2Learn
4. Real-World Example:

 When filling an online form, validation ensures that the


email format is correct, phone number is numeric, and
age is a number. Similarly, XML validation ensures
structured and error-free data storage.

Types of Validation in XML –


 There are two main types of XML validation:

Validation Type Definition Example Use Case

DTD (Document Defines the Simple XML


Type Definition) structure, documents where
elements, and strict rules are not
attributes of an required.
XML document.

XSD (XML More advanced Complex XML


Schema than DTD; defines applications like
Definition) data types, web services,
constraints, and databases.
rules for XML
elements.

------------------------------------------------------------------------------
7. Write Web Forms Fundamentals And Properties.
S[2019,2017].
Join Our Telegram Community - Aspire2Learn
Ans –
1. ASP.NET Web Forms is a part of the ASP.NET framework
used to build dynamic web applications. It follows an
event-driven programming model and allows developers
to create web pages with rich UI components.

2. Key Features of Web Forms –

 Event-Driven Programming: Controls trigger events


(like button clicks).

 ViewState Management: Maintains user data between


postbacks.

 Code-Behind Model: Separates design (HTML) and logic


(C# or VB.NET).

 Rich Server Controls: Pre-built UI elements like


GridView, TextBox, etc.

 State Management: Supports Session, Cookies,


ViewState, and Application State.

Structure of an ASP.NET Web Form


 A Web Form in ASP.NET consists of:

 .aspx file (UI Design)

 .aspx.cs file (Code-Behind - C# Code)

Join Our Telegram Community - Aspire2Learn


 Web.config file (Configuration settings)

Real-World Example of Web Form Fundamentals in


ASP.NET

Scenario: Online Shopping – Adding Items to Cart

 Imagine you are shopping online. You select a product,


enter quantity, and click "Add to Cart". The page
processes the input and displays the total price.

ASP.NET Web Form Example: Shopping Cart

1. Web Form (Shopping.aspx)

Join Our Telegram Community - Aspire2Learn


2. Code-Behind (Shopping.aspx.cs)

Join Our Telegram Community - Aspire2Learn


How It Works?
 User enters quantity (e.g., 3).

 Clicks "Add to Cart", triggering btnAddToCart_Click().

 The total price (quantity * 100) is calculated.

 The result is displayed in lblTotalPrice.

 Example Output: If user enters 3, it shows:

 "Total Price: ₹300"

Daily Life Connection –


 This is similar to adding products to an online shopping
cart, where the total price updates based on the entered
quantity.

 The ASP.NET Web Form handles user input, processes


logic, and displays output dynamically.

------------------------------------------------------------------------------
8. Explain Calendar Control In Short. S[2019,2017].
Ans -
1. The Calendar Control in ASP.NET is a built-in web control
used to display a calendar and allow users to select dates.
Join Our Telegram Community - Aspire2Learn
It is highly customizable and can be used for scheduling,
booking systems, date selection, and event-driven
applications.

2. Key Features:

 Displays a calendar with days, months, and years.

 Allows users to select a single date or a range of dates.

 Supports event handling for date selection and


navigation.

 Customizable appearance (colors, fonts, styles).

 Supports week numbers and different date formats.

3. Real-World Example:

 Online booking system: Users can select check-in and


check-out dates for hotel reservations.

 Task Scheduler: Users select a date to schedule a task or


appointment.

Syntax of Calendar Control -

Join Our Telegram Community - Aspire2Learn


 This simple calendar control will display a default
calendar in a web form.

Properties of Calendar Control –

Property Description Example


Value

SelectedDate Gets or sets the Calendar1.SelectedDat


selected date. e=
DateTime.Now;

SelectionMod Specifies single Day, Week,


e date selection or Month
multiple date
selection.

VisibleDate Sets the currently Calendar1.VisibleDate


displayed = new DateTime(2025,
month/year. 05, 01);

ShowGridLine Displays grid lines True /


s between calendar False
cells.

ShowTitle Displays the title True /


of the False
month/year.
Join Our Telegram Community - Aspire2Learn
ShowNextPre Shows previous True /
vMonth and next month False
navigation links.

DayStyle Allows custom CssClass="dayStyle"


styling for regular
days.

Example: Basic Calendar Control in ASP.NET –

Goal: Create a simple calendar where users select a date, and


it displays the selected date.

Code Example (Calendar in ASP.NET Web Forms) –

Join Our Telegram Community - Aspire2Learn


Code-Behind (C# - Calendar Selection Handling)

Join Our Telegram Community - Aspire2Learn


Expected Output:

When a user selects March 20, 2025, the label displays:


------------------------------------------------------------------------------
Test Your Knowledge Through
Aspire2Learn Online Quiz –

------------------- Aspire2Learn Online Quiz-------------------

------------------------------------------------------------------------------
Aspire2Learn Feedback Form –
- Your Voice, Our Priority

----------------------- Feedback Link -----------------------------


------------------------------------------------------------------------------

Join Our Telegram Community - Aspire2Learn


Join Our Telegram Community - Aspire2Learn
Join Our Telegram Community - Aspire2Learn

You might also like