Web The End Pyq
Web The End Pyq
a. Data Binding
Data binding connects a user interface (UI) element to a data source, enabling automatic data transfer
c. MVC
MVC stands for Model-View-Controller. It is a design pattern used in ASP.NET for separating application logic (Model),
user interface (View), and input control (Controller).
d. WSDL
WSDL (Web Services Description Language) is an XML-based file that describes how to interact with a web service. It
specifies the available operations, data types, and access methods.
e. AJAX
AJAX (Asynchronous JavaScript and XML) allows web pages to update asynchronously by exchanging data with the
server in the background. In ASP.NET, it improves responsiveness by refreshing parts of a page without reloading the
entire page, enhancing user experience.
Q.2 What is data binding in ASP.NET? How does it improve the user experience?
Data binding in ASP.NET is the process of linking UI elements like GridView, ListBox, DropDownList, etc., to data
sources such as databases, arrays, or collections. This allows data to be displayed dynamically without manual code
to update each item.
• Simple Data Binding – for single values, like a label showing a database field.
• Complex Data Binding – for controls like GridView or Repeater that display lists or tables.
Q.3 Compare ADO with ADO.NET. What are the differences between them?
Data Access Uses COM-based recordsets Uses datasets and data readers
Concurrency Not suitable for web apps Supports multiple users easily
Q.4 How do you create a connection in ADO.NET using SQLDB?
To create a connection in ADO.NET with SQL Server, you use the SqlConnection class from the System.Data.SqlClient
namespace. A connection string is required to define the database source, credentials, and other settings.
Steps:
using System.Data.SqlClient;
con.Open();
This opens a connection to the database. After operations, always close the connection using con.Close();. This
method ensures efficient use of resources.
Caching in ASP.NET is a technique to store frequently accessed data in memory for faster access. Instead of fetching
data from a database or processing it every time, the data is retrieved from cache, which significantly reduces
response time and server load.
Types of Caching:
Benefits:
Custom controls in ASP.NET are user-defined controls that extend the functionality of existing controls or provide new
features. They can be reused across multiple pages or projects and are compiled into a DLL for deployment.
Types:
• User Controls (.ascx) – Easy to create but only usable within the same application.
{
protected override void OnClick(EventArgs e)
base.OnClick(e);
Q.7
<body>
</form>
</body>
csharp
// GridViewExample.aspx.cs
using System;
using System.Data;
using System.Web.UI;
namespace WebApp
if (!IsPostBack)
dt.Columns.Add("ID");
dt.Columns.Add("Name");
dt.Columns.Add("Course");
dt.Rows.Add("1", "John", "ASP.NET");
GridView1.DataSource = dt;
GridView1.DataBind();
aspx
<body>
</asp:Panel>
</form>
</body>
csharp
// PanelExample.aspx.cs
using System;
namespace WebApp
Operators are symbols used to perform operations on variables and values. ASP.NET (C#) supports several types of
operators:
1. Arithmetic Operators: +, -, *, /, %
o Assign values.
6. Conditional Operator: ?:
7. Null-Coalescing Operator: ??
(b). Define the concept of Validation Controls in ASP.NET. Discuss types of validation controls used in ASP.NET with
properties.
1. RequiredFieldValidator
• Definition: This control ensures that the user does not leave the specified input field empty. It is the
simplest form of validation and is used to make sure that mandatory fields, such as name, email, or
password, are filled out before the form is submitted.
• Example:
2. RangeValidator
• Definition: This validator checks whether the entered value lies within a defined range of values. It can
validate numeric inputs, dates, or strings and is especially useful when you want to restrict user input to a
specific interval, like age limits or valid date ranges.
• Example:
3. RegularExpressionValidator
• Definition: This control validates user input based on a regular expression pattern, which defines the
expected format of the input. It’s perfect for checking fields that require a specific structure, such as email
addresses, phone numbers, or postal codes.
• Example:
4. CompareValidator
• Definition: This validator compares the value of one input control with another or a constant value. It’s
commonly used to check if two fields have matching values, such as in password confirmation fields or to
ensure a date is after another.
• Example:
5. ValidationSummary
• Definition: The ValidationSummary control is used to display a consolidated list of all validation errors on
the page. It helps to provide a better user experience by summarizing the issues at the top or in a message
box rather than displaying separate error messages for each control.
• Example:
Q.9 (a). What is the use of Global.aspx file? Explain the major events defined in global.asax file
The Global.asax file, also known as the ASP.NET application file, is used to handle application-level events raised by
ASP.NET or by HTTP modules. This file allows developers to write code for events that apply to the entire web
application, such as application startup, session start, application errors, etc.
The Global.asax file does not handle page-specific code—instead, it is used to manage global application behavior.
1. Application_Start
csharp
2. Session_Start
csharp
3. Application_BeginRequest
csharp
4. Application_Error
csharp
Exception ex = Server.GetLastError();
5. Session_End
csharp
6. Application_End
(b). What is Configuration File in ASP.NET? Define the types of Configuration File with any two settings
In ASP.NET, a configuration file is an XML-based file used to define application-level settings and behaviors. It allows
developers and administrators to control and customize how the web application works without modifying the
source code.
The most commonly used configuration file is Web.config, and at the system level, there is Machine.config. These
files store settings such as database connections, security, session state, custom error pages, etc.
1. Web.config
o Each ASP.NET web application can have its own Web.config file.
o You can have multiple Web.config files in subdirectories to override settings locally.
o Commonly used for: database connection strings, authentication modes, custom errors, session
state, etc.
2. Machine.config
o You should not modify it directly unless necessary, as changes affect all applications on the machine.
1. Connection Strings:
xm
<connectionStrings>
</connectionStrings>
xml
<system.web>
</customErrors>
</system.web>
Q.10 (a). What is Session? Define the types of session in ASP.NET. Write a code to accept value as a university
name from the user in a textbox and display it on another page using Session.
Definition of Session:
A Session in ASP.NET is a server-side storage mechanism that allows you to store and retrieve user-specific
information for the duration of the user's visit (session) to a web application. Each user who accesses a web
application is given a unique session ID, and their data is stored separately using this ID.
Session variables help preserve user data across multiple web pages during the user's visit.
1. InProc (In-Process):
2. StateServer:
o Useful for web farms where sessions need to persist across multiple servers.
3. SQLServer:
o Allows storage of session data in a custom-defined store, like Redis or file system.
5. Off:
html
Page1.aspx.cs (Code-Behind):
csharp
Session["UniversityName"] = txtUniversity.Text;
Response.Redirect("Page2.aspx");
html
Page2.aspx.cs (Code-Behind):
csharp
Q.10 (b). What are the differences between SqlCommand and SqlConnection class? Write a code to insert and
update data into a SQL Server database from an ASP.NET web page.
Purpose Executes SQL queries or commands Establishes connection with SQL Server
Usage Required to perform insert, update, delete Required to connect to the database
Code to Insert and Update Data in SQL Server from ASP.NET Web Page
html
using System;
using System.Data.SqlClient
string query = "INSERT INTO Students (ID, Name) VALUES (@ID, @Name)";
cmd.Parameters.AddWithValue("@ID", txtID.Text);
cmd.Parameters.AddWithValue("@Name", txtName.Text);
conn.Open();
cmd.Parameters.AddWithValue("@ID", txtID.Text);
cmd.Parameters.AddWithValue("@Name", txtName.Text);
conn.Open();
Q.11 (a). Define the concept of Web Service and types of Web Service. Draw the generic architecture of a Web
Service.
A Web Service is a software component that allows different applications to communicate and share data over the
internet using standardized protocols such as HTTP, XML, and SOAP. It enables interoperability between different
platforms and technologies (like Java, .NET, PHP).
Web services follow a client-server model where the service provider publishes the service, and the consumer or
client accesses it using web protocols.
Web services are platform-independent, which means a service written in one language can be used by an
application written in another
o Provides strong typing, error handling, and support for complex data types.
o Offers features like transactions, security, and multiple transport options (HTTP, TCP).