ASP by Akatsuki
ASP by Akatsuki
NET
SHORT QUESTIONS
1. What is ASP.NET?
ASP.NET means "Active Server Pages" which is frontend language & it is
established & supported by Microsoft
5. Explain ISPOSTBACK
IsPostBack is a propety of the Asp.Net page that tells whether or not the
page is on its initial load or if a user has perform a button on your web
page that has caused the page to post back to itself.
DESIGNED BY AKATSUKI
1
ASP.NET
DESIGNED BY AKATSUKI
2
ASP.NET
Themes are a feature of ASP.NET that help you maintain a consistent
look and feel across your web pages and controls. Themes can also
improve the performance and security of your web application by
reducing the bandwidth and hiding the confidential state data from the
client
DESIGNED BY AKATSUKI
3
ASP.NET
The DataAdapter has properties of type Command, which represent the
ways it can query, insert, delete, and update the database.
DESIGNED BY AKATSUKI
4
ASP.NET
26. What is the difference between page and Web user control?
A page and a Web user control are both components that can be used to
create dynamic web applications using ASP.NET. However, they have
some differences in their structure, functionality, and usage.
A page is a file that has the extension .aspx and contains an @ Page
directive that defines its configuration and other properties
A Web user control is a file that has the extension .ascx and contains an
@ Control directive that defines its configuration and other properties
DESIGNED BY AKATSUKI
5
ASP.NET
DESIGNED BY AKATSUKI
6
ASP.NET
DESIGNED BY AKATSUKI
7
ASP.NET
LONG QUESTIONS
1. Write a note on .NET Framework.
.NET Framework:
NET is Software Platform. It is a language neutral environment for
developing applications. It also provides an execution environment and
integration with various programming languages for building, deploying
and running web-based and standalone enterprise applications. All
aspects to manage the program execution like memory allocation for data
storage and instructions, granting and denying permission to the
application, managing execution of application and reallocation of
memory for resources which are not needed is managed easily in
ASP.NET. It consists of class libraries and reusable components.
The block diagram of .NET framework is as follows:
DESIGNED BY AKATSUKI
8
ASP.NET
DESIGNED BY AKATSUKI
9
ASP.NET
When the request comes from the .aspx page, it is given for parsing to asp.net
engine. Then a combined page class is generated from that parsed page and
the code behind class and then it is compiled. At last, the instance of the class
is created and provided to the user.
Page Life Cycle Stages:
1. Page Request: This is when the page is first requested from the server.
When the page is requested, the server checks if it is requested for the
first time.
2. Start: In this phase, 2 objects, known as the Request and Response
object are set. If the request is an old request or post back, the
IsPostBack property of the page is set to true. The UICulture property of
the page is also set.
3. Page Initialization: In this phase, controls on the page are available and
each control's UniquelD property is set. A master page and themes are
also applied to the page if applicable
4. Load: During this phase, if the current request is a postback, control
properties are set to utilize the view state and control state values like if
a textbox is supposed to have a default value, that value is loaded during
the page load time.
5. Validation: In this phase, when the validation controls are present on
the page, than on its successful execution, IsValid property of the page is
set to true
6. Postback Event Handling: In this phase, control event handlers are
called if the request is a postback. That means this event is triggered if
the same page is being loaded again. This happens in response to an
earlier event.
7. Rendering: Before this phase, view state is saved for the page and all
controls. During this stage, the page calls the Render() method for each
control and writes its output to the OutputStream object of the page's
Response property.
8. Unload: The unload method takes after the page is fully loaded and is
ready to terminate. At this point, rendered page is sent to the client and
page properties such as Response and Request are unloaded and clean-
up is done.
3. Explain Request object.
Request object is used to retrieve information from a user. It is an
instance of the system.Web.HttpRequest class. Request Object's
collections, properties, and methods are described below:
DESIGNED BY AKATSUKI
10
ASP.NET
DESIGNED BY AKATSUKI
11
ASP.NET
The main function of CLR is to convert the MSIL code to native code and
then execute the program. The managed code a code that is developed
with a language compilerthat targets the CLR is compiled only when it is
needed, that means it converts the appropriate instructions when each
functin is called.
The unmanaged code - a code thaat is developed without considering the
conventions and requirements of CLR, is executed with minimal service
of CLR. The CLR's JIT (Just-in Time) compilation converts MSIL to native
code on demant at application run.
During the execution of the program, the CLR provides functionaloty such
as memory, Debugging, Exception Handling, Security and versioning
support to any languages that target it. In short, When .NET programs are
executed, the CLR activates the JIT compiler.
The JIT Compiler converts MSIL into native code on demand basis. Thus
the program executes as a native code to run the program fast. That is
how NET framework achieves the portability.
5. Write a note on Response object.
Response object is used to provide output to the user from the server.
ASP.NET provides a class called HttpResponse which is defined in the
namespace called System.Web. Response object's collections, properties,
and methods are described below:
DESIGNED BY AKATSUKI
12
ASP.NET
DESIGNED BY AKATSUKI
13
ASP.NET
DESIGNED BY AKATSUKI
14
ASP.NET
DESIGNED BY AKATSUKI
16
ASP.NET
and id attribute: < input type="text" ld="testtext" size="40"
runat="server">
Advantages of using HTML Server Controls: Although ASP.NET server
controls can perform every job accomplished by the HTML server
controls, the later controls are useful in the following cases:
Using static tables for layout purposes.
Converting a HTML page to run under ASP.NET
11.Explain gridview control.
The GridView control enables us to display, select, sort, page, and edit
data items such as database records.
The GridView control in ASP.NET is a powerful and flexible data-bound
control used to display tabular data from various data sources, such as
databases, XML, or object collections. It is commonly used in web
applications to create data grids or tables with features like sorting,
paging, and editing. Here's a detailed explanation of the GridView control:
Key Features and Properties of GridView Control:
1. Data Binding: You can bind the GridView to a data source using the
`DataSource` property. This can be a database query, an object collection, or
other data sources like XML or JSON.
2. Auto-Generation of Columns: The GridView can automatically generate
columns based on the data source schema, which simplifies the setup process.
You can also define custom columns manually.
3. Sorting: GridView provides built-in sorting functionality. Users can click on
column headers to sort the data in ascending or descending order.
4. Paging: You can enable paging to split large datasets into manageable pages.
This is crucial for performance when dealing with extensive data.
5. Editing and Updating: GridView supports inline editing of data rows. You can
specify which columns are editable and handle events like `RowEditing` and
`RowUpdating`.
6. Deleting and Inserting: It allows users to delete rows and insert new rows.
You can handle events like `RowDeleting` and `RowInserting` for custom logic.
7. Templates: GridView supports templates for customizing the appearance and
layout of data rows, headers, footers, and more. You can use templates to
display data in a more user-friendly way.
8. Data Formatting: You can format data within columns using various
formatting options, making it suitable for displaying dates, currency, or custom
text.
DESIGNED BY AKATSUKI
17
ASP.NET
9. Data Source Controls: GridView works well with data source controls like
SqlDataSource and ObjectDataSource, simplifying data retrieval and
management.
10. Client-Side Integration: It can be integrated with client-side scripts and AJAX
for enhanced user interactions without full-page postbacks.
Here's a simplified example of using a GridView control in ASP.NET:
html
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true">
</asp:GridView>
In this basic example, the GridView is configured to auto-generate columns
based on the data source. In your code-behind, you would set the `DataSource`
property and call the `DataBind()` method to populate the GridView with data.
The GridView control is highly customizable and can be extended to meet
specific requirements in web applications, making it a fundamental tool for
displaying and interacting with tabular data.
DESIGNED BY AKATSUKI
18
ASP.NET
13.Write a note on SITEMAPPATH.
The SiteMapPath control is also used to display the Navigation
information on the site.
It display the current page's context within the entire structure of a
website. You can bind this control to TreeView and Menu controls.
SiteMapPath is a web server control that is used to display a set of text
or image hyperlinks that enable users to more easily navigate a web site,
while taking a minimal amount of page space.
It reflects the data provided by the SiteMap object and shows the current
position of the user within the site hierarchy. It also allows the user to go
back to any previous page in the navigation path.
To add SiteMapPath to your web page, you need to use the
asp:SiteMapPath tag and set its properties and styles according to your
preferences.
You can also use templates to customize the appearance and behavior of
each node type, such as RootNodeTemplate, CurrentNodeTemplate,
ParentNodeTemplate, and PathSeparatorTemplate .
14.Short note:
1. USER CONROL
2. USER PROFILE
USER CONROL:
User control in ASP.NET is a way to create reusable components that can
be embedded in web pages. User control is a file with .ascx extension that
contains HTML and server-side code.
User control can have properties, methods, and events, just like a web
form or a custom server control. User control can also contain other
ASP.NET controls, such as text boxes, labels, buttons, and so on.
To create a user control, you need to use Visual Studio or any text editor
that supports ASP.NET. You can design the user control visually or write
the code manually. You can also use code-behind files to separate the
presentation logic from the business logic. You can test the user control
by adding it to a web form and running the application.
DESIGNED BY AKATSUKI
19
ASP.NET
User control is useful for creating common UI elements that can be shared
across multiple pages or applications.
For example, you can create a user control for a contact form, a navigation
menu, a header, or a footer. You can then include the user control in any
page that needs it by using the asp:UserControl tag or the @Register
directive.
You can also customize the user control by passing parameters or setting
attributes.
USER PROFILE:
User profile in ASP.NET is a feature that allows you to store and retrieve
user-specific information for your web application. You can use user
profile to customize the user experience, such as remembering their
preferences, settings, or personal data. User profile can also be used to
track the user’s activity, such as the last visit time, the number of visits, or
the pages viewed.
To use user profile in ASP.NET, you need to do the following steps:
Configure the profile provider in the web.config file. The profile provider
is responsible for storing and retrieving the user profile data from a
persistent source, such as a database or a file system. You can use the
default SqlProfileProvider or create your own custom profile provider.
Define the user profile properties in the web.config file. The user profile
properties are the attributes that you want to store for each user, such as
name, email, age, gender, etc. You can specify the data type, default
value, and serialization mode for each property. You can also group the
properties into profiles for different types of users.
Access and modify the user profile data in your code. You can use the
Profile object to get or set the values of the user profile properties. The
Profile object is available in any page or class that inherits from Page or
UserControl. You can also use the ProfileManager class to perform bulk
operations on user profiles, such as deleting, migrating, or finding profiles.
15.Explain checkboxlist control.
A checkboxlist control is a web server control that allows you to display a list
of items with checkboxes that the user can select or clear. The checkboxlist
control is useful for creating multiple-choice questions, surveys, or
preferences. The checkboxlist control has the following features and
properties:
It can be bound to a data source, such as a database, an XML file, or an
array, to dynamically generate the list items.
DESIGNED BY AKATSUKI
20
ASP.NET
It has an Items collection that contains the ListItem objects that represent
each item in the list. You can access and modify the items by using the
collection methods and properties, such as Add, Remove, Count, and
Clear.
It has a SelectedIndex property that returns the index of the first selected
item in the list, or -1 if no item is selected. You can also use the
SelectedIndices property to get a collection of all the selected indices in
the list.
It has a SelectedItem property that returns the first selected item in the
list, or null if no item is selected. You can also use the SelectedItems
property to get a collection of all the selected items in the list.
It has a SelectedValue property that returns the value of the first selected
item in the list, or an empty string if no item is selected. You can also use
the SelectedValues property to get a collection of all the selected values
in the list.
16.Explain OOP concept.
OOP stands for Object-Oriented Programming, which is a programming
paradigm that organizes data and behavior into reusable units called objects.
Objects have properties that describe their state and methods that define
their actions. Objects can also interact with each other through messages
or events.
ASP.NET is a web development framework that supports OOP concepts in
various ways. For example, ASP.NET web pages are derived from the Page
class, which is an object that has properties and methods for handling
requests, rendering output, and managing the page life cycle.
ASP.NET web controls are also objects that inherit from the Control class,
which provides common functionality for rendering HTML elements,
handling events, and maintaining state.
ASP.NET also allows developers to create their own custom classes and
objects to implement business logic, data access, or presentation logic.
Developers can use languages such as C#, VB.NET, or JScript.NET to write
OOP code in ASP.NET applications.
These languages support OOP features such as abstraction,
encapsulation, inheritance, and polymorphism, which enable developers
to create modular, reusable, and maintainable code.
17.Explain REPEATER AND LISTBOX.
REPEATER: A REPEATER in ASP.NET is a web server control that allows you to
display a repeated list of items that are bound to the control. The REPEATER
control can be bound to a data source, such as a database, an XML file, or
DESIGNED BY AKATSUKI
21
ASP.NET
another list of items. The REPEATER control is useful for creating custom
layouts and formats for displaying data, such as tables, lists, or grids.
The REPEATER control has five templates that define how the data is
rendered:
HeaderTemplate: This template is used for elements that you want to
render once before the item section.
FooterTemplate: This template is used for elements that you want to
render once after the item section.
ItemTemplate: This template is used for elements that are rendered once
per item in the data source. It is the main template that displays the data.
AlternatingItemTemplate: This template is used for elements that are
rendered every second item in the data source. This allows you to
alternate the appearance of the items.
SeparatorTemplate: This template is used for elements that are rendered
between each item, such as line breaks or commas.
LISTBOX: A LISTBOX in ASP.NET is a web server control that allows you to
display a list of items with checkboxes that the user can select or clear. The
LISTBOX control is useful for creating multiple-choice questions, surveys, or
preferences.
The LISTBOX control has the following features and properties:
It can be bound to a data source, such as a database, an XML file, or another
list of items, to dynamically generate the list items.
It has an Items collection that contains the ListItem objects that represent
each item in the list. You can access and modify the items by using the
collection methods and properties, such as Add, Remove, Count, and Clear.
It has a SelectedIndex property that returns the index of the first selected
item in the list, or -1 if no item is selected. You can also use the
SelectedIndices property to get a collection of all the selected indices in the
list.
It has a SelectedItem property that returns the first selected item in the list,
or null if no item is selected. You can also use the SelectedItems property to
get a collection of all the selected items in the list.
It has a SelectedValue property that returns the value of the first selected
item in the list, or an empty string if no item is selected. You can also use the
SelectedValues property to get a collection of all the selected values in the
list.
It has a RepeatColumns property that specifies the number of columns or
rows to display in the list. The value depends on whether you use Table or
Flow layout and Horizontal or Vertical direction.
DESIGNED BY AKATSUKI
22
ASP.NET
It has a TextAlign property that specifies how the text is aligned with respect
to the checkbox. You can choose between Left and Right alignments.
18.What is theme?Explain various way to apply theme.
Theme: They are skin template that allows you to define the look of pages
and controls, which can then be applied to all the pages in your application
to provide consistent look for your application. It applies to any Server
control. It is used to set Height, width, Forecolor, backcolor, bordercolor of
any asp.net server controls
Applies to all the server controls Is applied on the server rather than in the
browser But we cannot apply multiple themes to a single page. Only one
theme we can apply for a single page.
But themes does not support cascading For property values defined in a
theme, the theme property overrides the property values declaratively set
on a control, unless the StyleSheetTheme property is explicitly defined.
Can be applied through Configuration Files.
All theme and Skin files should be placed in a special Asp.net folder called the
"ApP_Themes in order for the themes to work and behave normally.
Each theme should be associated with at least one Skin file.
But a theme can define multiple properties of a control not just style
properties such as we can specify the graphies property for a control,
template layout of a GridView control etc.
There are two ways to Apply Theme to your web form
1. Add Theme Attribute inside @page Directive Theme="Skin File"
(<%@Page Language="CH" MasterPageFile="/MasterPage.master"
AutoEventWireup="true" CodeFile="Registration.aspx.cs"
Inherits="Registration" Theme="SkinFile"9%>)
2. Right click on page-> goto properties-> In Theme property select the
SkinFile that you have created. Note: This step is only useful when you
have not applied master page to the form.
19.Write code snipped to fill dropdown from the database.
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles
Me.Load
If Not IsPostBack Then
Dim connectionString As String =
ConfigurationManager.ConnectionStrings("dbConnection").ConnectionS
tring
DESIGNED BY AKATSUKI
23
ASP.NET
Dim command As New SqlCommand("SELECT ProductID, ProductName
FROM Products", connection)
Dim adapter As New SqlDataAdapter(command)
Dim products As New DataTable()
adapter.Fill(products)
ddlProducts.DataSource = products
ddlProducts.DataTextField = "ProductName"
ddlProducts.DataValueField = "ProductID"
ddlProducts.DataBind()
ddlProducts.Items.Insert(0, New ListItem("--Select Product--", "0"))
End If
End Sub
20.Difference between CSS and skin file.
CSS:
Applies to all HTML Controls
Is applied on the Client Side in the Browser
We can apply multiple style sheets to a single page
The CSS supports cascading
The CSS cannot override the property values defined for a control.
Cannot be applied through the configuration files
Can be used directly via a reference to the css file location
Do not require any other resource like Skin files
In case of CSS you can define only style properties
Themes:
Applies to all the server controls
Is applied on the server rather than in the browser
But we cannot apply multiple themes to a single page. Only one theme
we can apply for a single page.
But themes does not support cascading
For property values defined in a theme, the theme property overrides the
property values declaratively set on a control, unless the
StyleSheetTheme property is explicitly defined.
Can be applied through Configuration Files.
All theme and Skin files should be placed in a special Asp.net folder called
the "ASP_Themes in order for the themes to work and behave normally.
Each theme should be associated with at least one Skin file.
But a theme can define multiple properties of a control not just style
properties such as we can specify the graphies property for a control,
template layout of a GridView control etc.
DESIGNED BY AKATSUKI
24
ASP.NET
DESIGNED BY AKATSUKI
26
ASP.NET
DESIGNED BY AKATSUKI
27
ASP.NET
track the user’s activity, such as the last visit time, the number of visits, or
the pages viewed.
To use user profile in ASP.NET, you need to do the following steps:
Configure the profile provider in the web.config file. The profile provider
is responsible for storing and retrieving the user profile data from a
persistent source, such as a database or a file system. You can use the
default SqlProfileProvider or create your own custom profile provider.
Define the user profile properties in the web.config file. The user profile
properties are the attributes that you want to store for each user, such as
name, email, age, gender, etc. You can specify the data type, default
value, and serialization mode for each property. You can also group the
properties into profiles for different types of users.
Access and modify the user profile data in your code. You can use the
Profile object to get or set the values of the user profile properties. The
Profile object is available in any page or class that inherits from Page or
UserControl. You can also use the ProfileManager class to perform bulk
operations on user profiles, such as deleting, migrating, or finding profiles.
26.Explain global.asax file in detail. OR write a note on global
application class.
Global.asax File:
The `Global.asax` file is a special file in ASP.NET that serves as the Global
Application Class.
It contains application-level events and code that are executed during the
application's lifecycle. Some of the key events in the `Global.asax` file
include `Application_Start`, `Application_End`, `Session_Start`, and
`Session_End`.
You can use these events to perform tasks like initializing application-wide
settings, handling errors, and managing session data.
In ASP.NET, the "global.aspx" file, also known as the Global Application
Class file, is a special file used to define and handle global application-level
events and settings. It serves as a central location for managing
application-wide configurations, authentication, and event handling.
Here are some key points about the "global.aspx" file:
Global.asax File: The file is named "Global.asax" and is typically located in
the root directory of an ASP.NET web application. It has a code-behind file
called "Global.asax.cs" where you write the server-side code to handle
events.
DESIGNED BY AKATSUKI
28
ASP.NET
DESIGNED BY AKATSUKI
29
ASP.NET
machine. It is easy way to maintain user's information. Cookies are Fast
accessing.
28.Write a note on exception handling.justify Exception handling
play major role to improve quality of software.
Exception Handling:
Exception handling is a crucial aspect of software development that involves
dealing with unexpected or exceptional situations that may arise during the
execution of a program. Exception handling improves software quality in several
ways:
Robustness: Properly handling exceptions makes your software more
robust and resilient to unexpected errors. It prevents crashes and
provides graceful error recovery mechanisms.
Debugging: Exception information helps developers identify and diagnose
issues during development and testing, making it easier to fix problems.
User Experience: Handling exceptions gracefully provides a better user
experience by displaying helpful error messages and preventing
application crashes.
DESIGNED BY AKATSUKI
30
ASP.NET
2. State Server Mode: In this mode session data is stored in separate server.
3. SQL Server Mode: In this session is stored in the database. It is a secure
mode.
4. Custom Mode: Generally, session data is stored in InProc, Sql Server,
State server, etc. but ASP.NET allows session data to be stored with other
new techniques developed by developer also.
30.Difference between HTML Server controls and Web Server
Controls.
Html Server: The HTML server controls are basically the standard HTML
controls enhanced to enable server side processing.
The HTML controls such as the header tags, anchor tags, and input
elements are not processed by the server but are sent to the browser for
display
hey are specifically converted to a server control by adding the attribute
runat="server" and adding an id attribute to make them available for
server-side processing.
For example, consider the HTML input control: <input type="text"
size="40"> It could be converted to a server control, by adding the runat
and id attribute: < input type="text" ld="testtext" size="40" runat="server">
Advantages of using HTML Server Controls: Although ASP.NET server
controls can perform every job accomplished by the HTML server controls,
the later controls are useful in the following cases:
Using static tables for layout purposes.
Converting a HTML page to run under ASP.NET
31.What is CSS? Discuss how CSS is more powerful than HTML (5)
formatting .
CSS (Cascading Style Sheets):
CSS is a style sheet language used for describing the presentation and
formatting of web documents, including HTML. It is more powerful than
HTML in terms of formatting because:
- Separation of Concerns: CSS separates the content (HTML) from the
presentation (styling). This makes it easier to maintain and update the
appearance of a website without changing the underlying content.
- Reusability: CSS allows you to define styles once and apply them to
multiple elements or pages, promoting code reusability.
- Control: CSS offers fine-grained control over the layout, colors, fonts,
and other aspects of a webpage, enabling precise and consistent
styling.
DESIGNED BY AKATSUKI
31
ASP.NET
- Media Queries:CSS allows responsive design by using media queries to
adapt styles based on the device or screen size.
DESIGNED BY AKATSUKI
32
ASP.NET
3. Validation Controls: ASP.NET provides validation controls like
RequiredFieldValidator and RegularExpressionValidator to validate
user input easily.
4. Data Controls: These controls, such as Repeater and DataGrid, help in
displaying data from various sources like databases.
5. User Controls: User controls are custom controls created by
developers that can be reused across multiple pages.
6. AJAX Controls : ASP.NET AJAX controls enable you to build
responsive and interactive web applications.
7. Login Controls: These controls, like Login and PasswordRecovery,
simplify user authentication and password management.
Now, let's explain the TreeView control in detail:
TreeView Control:
The TreeView control in ASP.NET is used to display hierarchical data in a
tree-like structure, much like the folder structure in Windows Explorer. It's
particularly useful for representing categories, organizational structures, or
any data with a parent-child relationship.
Here are its key features and properties:
- Nodes: The TreeView consists of nodes, each representing an item in the
hierarchy. You can add nodes manually in the markup or programmatically
in code-behind.
- Hierarchical Structure: Nodes can have child nodes, creating a hierarchical
structure. This is ideal for displaying parent-child relationships.
- Templates: You can customize the appearance of nodes using templates for
various states such as normal, selected, and expanded.
- Data Binding: You can bind the TreeView to data sources like XML,
databases, or object collections. This allows dynamic population of the tree.
- Expand/Collapse: Users can expand and collapse nodes to navigate through
the hierarchy.
- Client-Side Events: You can handle client-side events for user interactions
like node selection or expansion without postbacks, improving
performance.
34.What are the advantages of themes over CSS. Explain various
ways to apply skin file.
Theme: They are skin template that allows you to define the look of pages
and controls, which can then be applied to all the pages in your
DESIGNED BY AKATSUKI
33
ASP.NET
application to provide consistent look for your application. It applies to any
Server control. It is used to set Height, width, Forecolor, backcolor, bordercolor
of any asp.net server controls
Applies to all the server controls
Is applied on the server rather than in the browser
But we cannot apply multiple themes to a single page. Only one theme
we can apply for a single page.
But themes does not support cascading
For property values defined in a theme, the theme property overrides the
property values declaratively set on a control, unless the
StyleSheetTheme property is explicitly defined.
Can be applied through Configuration Files.
All theme and Skin files should be placed in a special Asp.net folder called
the "ApP_Themes in order for the themes to work and behave normally.
Each theme should be associated with at least one Skin file.
But a theme can define multiple properties of a control not just style
properties such as we can specify the graphies property for a control,
template layout of a GridView control etc.
There are two types of control skins, default skins and named skin:
A default skin automatically applies to all controls of the same type when
a theme is applied to a page. A control skin is a default skin if it does not
have a SkiniD attribute. For example, if you create a defalt skin for a
Calendar control, the control skin applies to ll Calendar controls on pages
that use the theme. (Default skins are matched exactly by control type, so
that a Button control skin applies to all Button controls, but not to
LinkButton controls or to controls that derive from the Button object.
A named skin is a control skin with a SkinlD property set. Named skins do
not automatically apply to controls by type. Instead, you explicitly apply a
named skin to a control by setting the control's SkinlD property. Creating
named skins allows you to set different skins for different instances of the
same control in an application.
35.Differentiate between DataSet and DataReader. Explain Read()
method of DataReader with example.
DataSet vs. DataReader:
- DataSet: It's an in-memory, disconnected representation of data retrieved
from a database. It allows for data manipulation and can store multiple
tables. It's suitable for situations where data needs to be manipulated
extensively.
DESIGNED BY AKATSUKI
34
ASP.NET
DESIGNED BY AKATSUKI
35
ASP.NET
open connection object. It returns a stream of data that can be accessed
by using methods and properties, such as Read, NextResult, GetOrdinal,
GetName, GetValue, etc.
DataAdapter: This component is used to transfer data between the data
source and the DataSet object. It requires a connection object and one or
more command objects for performing select, insert, update, and delete
operations. It uses methods such as Fill and Update to populate and
modify the DataSet object.
DataSet: This component is used to store data in memory in a
disconnected and relational manner. It consists of DataTables,
DataColumns, DataRows, DataRelations, and Constraints that represent
the structure and the content of the data. It can be filled by using a
DataAdapter or by using methods such as ReadXml and WriteXml. It can
also be bound to various controls for displaying or editing data.
DataView: This component is used to sort, filter, or search data in a
DataTable or a DataSet. It provides a customized view of the data without
modifying the original data. It can also be bound to various controls for
displaying or editing data.
37.Differentiate between error and exception. Explain block level
exception handling .
Error vs. Exception:
Error: Errors are typically low-level issues that can lead to program crashes
or unexpected behavior. They often indicate serious problems like memory
exhaustion or hardware failures.
Exception: Exceptions are higher-level events that can be caught, handled,
and gracefully managed within the program. They represent situations where
the program can continue running but may need to take specific actions to
recover or report the issue.
Block-Level Exception Handling: This refers to catching and handling
exceptions at a specific block of code within the program. It allows you to
isolate error-handling logic to specific sections where exceptions are likely to
occur, enhancing code maintainability and robustness
38.Write a note on command builder.
A command builder is a class in the ADO.NET that helps developers
automatically generate SQL statements for updating, inserting, and deleting
data in a database. It is used in conjunction with a data adapter to
synchronize data between a Dataset and a database.
DESIGNED BY AKATSUKI
36
ASP.NET
To use a command builder, you first need to create a new instance of the
command builder class and associate it with a data adapter. You can then use
the command builder's methods to generate the SQL statements for the
desired operations.
The following are the steps on how to use a command builder in ASP.NET
Start stage: The page properties such as Request and Response are set. At
this stage, the page also determines whether the request is a post back or a
new request and sets the Is PostBack property. The page also sets the
UICulture property.
DESIGNED BY AKATSUKI
37
ASP.NET
Init stage: The page is initialized and the controls on the page are
instantiated. A master page and themes are also applied to the page if
applicable.
InitComplete stage: This stage is executed after the Init stage and before the
Load stage. This stage is typically used to initialize custom controls or perform
other tasks that need to be done before the controls are loaded.
Load stage: The controls on the page are loaded and their properties are set.
The view state is restored if it is available.
PostBack stage: This stage is executed when the page is posted back to the
server. This happens when the user submits a form or clicks a button.
LoadComplete stage: This stage is executed after the PostBack stage and
before the PreRender stage. This stage is typically used to perform tasks that
need to be done after the controls are loaded but before the page is
rendered.
PreRender stage: This stage is executed before the page is rendered to the
client. This stage is typically used to perform tasks such as validating the form
data or setting the values of the controls.
Render stage: The page is rendered to the client.
Unload stage: The page is unloaded from memory.
o The page processing sequence can be affected by the following factors:
o The type of request (postback or new request)
o The presence of custom controls
o The use of view state
o The use of master pages
It is important to understand the page processing sequence in order to write
code that works correctly at the appropriate stage of the page life cycle.
40.Differentiate between client side and server side validation.
Explain range and regular expression validator in detail.
Client-side validation is done in the user's browser using JavaScript. It is
performed before the form data is sent to the server, so it can provide a
quick and immediate feedback to the user. However, it is not as secure as
server-side validation because the user can disable or change the JavaScript
code.
DESIGNED BY AKATSUKI
38
ASP.NET
Server-side validation is done on the server side using code written in
VB.NET. It is performed after the form data is sent to the server, so it can be
more secure. However, it is slower than client-side validation because it
requires an additional round trip to the server.
Here are the details of range and regular expression validators in ASP.NET:
Range validator is used to validate the value of a control to be within a
specified range. For example, you can use a range validator to ensure that
the value of a textbox is between 1 and 100.Regular expression validator is
used to validate the value of a control against a regular expression.
A regular expression is a pattern that can be used to match text. For
example, you can use a regular expression validator to ensure that the
value of a textbox is a valid email address.
To use a range or regular expression validator in ASP.NET, you can add the
appropriate validation control to the form. For example, the following code
shows how to add a range validator to a textbox:
<asp:TextBox ID="txtNumber" runat="server"></asp:TextBox>
<asp:RangeValidator ID="valNumber" ControlToValidate="txtNumber"
MinimumValue="1" MaximumValue="100" ErrorMessage="The value must be
between 1 and 100." runat="server"></asp:RangeValidator>
The MinimumValue and MaximumValue properties of the RangeValidator
control specify the range of values that are allowed. The ErrorMessage
property specifies the error message that is displayed if the value is not
within the range.
To use a regular expression validator, you can use the
RegularExpressionValidator control. The ValidationExpression property of
the RegularExpressionValidator control specifies the regular expression that
is used to validate the value. The ErrorMessage property specifies the error
message that is displayed if the value does not match the regular expression.
Here are some of the benefits of using client-side validation:
It can provide a quick and immediate feedback to the user.
It can improve the user experience by preventing the user from
submitting invalid data.
It can reduce the load on the server by validating the form data before it
is sent to the server.
Here are some of the benefits of using server-side validation:
It is more secure than client-side validation because the user cannot
disable or change the code.
DESIGNED BY AKATSUKI
39
ASP.NET
It can be used to validate data that cannot be easily validated on the client
side, such as data that is stored in a database
41.Explain with example DataAdapter.
DataAdapter is a class in the ADO.NET that is used to fill and update data
between a DataSet and a data source. It is a bridge between a DataSet
and a data source.
The DataAdapter has two main methods:
Fill(): This method is used to fill a DataSet with data from a data source.
Update(): This method is used to update a data source with data from a
DataSet.
To use a DataAdapter, you first need to create a new instance of the
DataAdapter class and associate it with a DataSet and a data source. You can
then use the Fill() or Update() method to fill or update the DataSet.
For example:
Dim dataAdapter As New SqlDataAdapter("SELECT * FROM Products",
connectionString)
Dim dataSet As New DataSet()
dataAdapter.Fill(dataSet)
' Do something with the data in the DataSet
dataAdapter.Update(dataSet)
In this example, we first create a new instance of the SqlDataAdapter class and
specify the SQL SELECT statement that is used to fill the DataSet. We then create
a new instance of the DataSet class and associate it with the DataAdapter object.
We then use the Fill() method to fill the DataSet with data from the data source.
Finally, we use the Update() method to update the data source with changes
made to the DataSet.
Here are some of the benefits of using a DataAdapter:
DESIGNED BY AKATSUKI
40
ASP.NET
Target: This property is used to specify the target page location. It can be in
new window or same window.
Value: This property is used to specify the unique id to use in server side
events.
DESIGNED BY AKATSUKI
41
ASP.NET
TreeView: This control is used to display the item in tree view format. We
can expand and collapse the data list using tree root +/- sign.
DESIGNED BY AKATSUKI
42
ASP.NET
3.) The LoginStatus Control :- The Login Status control specifies whether a
particular user has logged on the website or not . When the user is not logged
in, this control display the Login text as a hyperlink When the user is logged in,
this control display the logout text as a hyperlink. To do this, Login Status control
uses the authentication section of the web.config file. This control provides the
following two views:-
1. LoggedIn --> It will be displayed, when the user is not Logged In.
2. Logout --> It will be displayed when the user is Logged In.
DESIGNED BY AKATSUKI
43
ASP.NET
6. ) CreateUserWizard control:-
This control uses the membership service to create a new user in the
membership data store. The CreateUserWizard control is provides by the
CreateUserWizard class and can be customized by using template and style
properties .Using this control any user can easily create an account and login to
the web page
7.) The ChangePassword Control:-
Using this control, user can easily change your existing password (old password)
on the ASP.NET Website. This control prompts uses to provide the current
password first and then set the new password first and then set the new
password. If the old password is not correct then new password can't be set.
This is also helps to send the email to the respective users about the new
password.This control is used ChangePassword class.
DESIGNED BY AKATSUKI
44