AWD - Notes
AWD - Notes
The attached PDF provides sample questions and answer guidelines as a reference only.
Actual exam questions may vary, though they may cover similar topics. Please use this as
supplementary material and review all relevant content.
Best of luck with your preparation!
UNIT I
1 What is namespace? Explain with the help of an example.
These are the .NET way of providing containers for application code, such that code and
its contents may be uniquely identified.
Namespaces are also used as a means of categorizing items in the .NET Framework.
C# code, by default, is contained in the global namespace. This means that items contained
in this code are accessible from other code in the global namespace simply by referring to
them by name. You can use the namespace keyword, however, to explicitly define the
namespace for a block of code enclosed in curly brackets.
Within a namespace, you can define nested namespaces, also using the namespace
keyword.
After namespaces are set up, you can use the using statement to simplify access to the
names they contain.
The System namespace is the root namespace for .NET Framework applications and
contains all the basic functionality you need for console applications. The System
namespace contains most of the basic types used in .NET applications.
Creating a Namespace:
namespace my_namespace{
public class class_name{ … } }
To conclude, all names defined in a .NET application, including variable names, are
contained in a namespace. Namespaces are hierarchical, and you often have to qualify
names according to the namespace that contains them in order to access them.
class Program
{
static void Main()
{
// Create an object of Document class
Document doc = new Document();
6 Define the accessibility modifiers: public, private, protected, internal, and protected
internal.
Private members of the base class are not accessible from a derived class, but public
members are. However, public members are accessible to both the derived class and
external code. Therefore, if you could use only these two levels of accessibility, you
couldn’t have a member that was accessible both by the base class and the derived class
but not external code.
To get around this, there is a third type of accessibility, protected, in which only derived
classes have access to a member. As far as external code is aware, this is identical to a
private member — it doesn’t have access in either case
Public: Accessible from anywhere within the same assembly or another assembly.
Private: Accessible only within the same class or struct.
Protected: Accessible within the same class or a derived class.
Internal: Accessible only within the same assembly, but not from another assembly.
Protected Internal: Accessible within the same assembly or from derived classes in
another assembly.
Private Protected: Accessible within the same class or derived classes within the same
assembly.
Create example of your own
8 What is an assembly? Explain the difference between public and private assembly.
When you compile an application, the CIL code created is stored in an assembly.
Assemblies include both executable application files that you can run directly from
Windows without the need for any other programs (these have a .exe file extension) and
libraries (which have a .dll extension) for use by other applications.
In addition to containing CIL, assemblies also include meta information and optional
resources. The meta information enables assemblies to be fully self-descriptive.
Of course, you won’t necessarily want to include everything required to run an application
in one place. You might write some code that performs tasks required by multiple
applications. In situations like that, it is often useful to place the reusable code in a place
accessible to all applications. In the .NET Framework, this is the global assembly cache
(GAC). Placing code in the GAC is simple — you just place the assembly containing the
code in the directory containing this cache.
Types of Assemblies:
1. Private Assembly: Used by a single application, stored in the application's directory.
2. Shared Assembly: Used by multiple applications, stored in the Global Assembly Cache
(GAC).
The CompareValidator control allows us to make comparison to compare data entered in
an input control with a constant value or a value in a different control.
Syntax:-
The RangeValidator control verifies that the input value falls within a predetermined range.
Syntax:-
The RequiredExpressionValidator allows validating the input text by matching against a
pattern of regular expression.
Syntax:-
The CustomValidator control allows writing application specific custom validation routines
for both the client side and the server side validation.
Syntax:-
Properties of Calendar:
1. SelectedDate: Gets or sets the selected date.
2. SelectedDates: Gets a collection of Date Time objects representing the selected dates.
3. VisibleDate: Gets or sets the date that specifies the month to display
Events:
1. SelectionChanged It is raised when a day, a week or an entire month is selected
5. List and describe the various file types used in an ASP.NET application.
.aspx- This file is basically an extension of ASP.NET Web Pages. It is used for web form
pages.
.ascx – This extension is basically used for web form user controls. The .ascx extension is
often used for consistent parts of a website like headers, footers etc.
.asmx – This extension is used for files that implement ASP.NET Web Services.
.vb – This extension is used for VisualBasic.NET code modules. These files are code-
behind files and are used to separate code from user interface.
.resx – These files are basically used for Windows Form Application for storing resources
such as text strings for internationalization of applications.
Global.asax – These files are basically used to define Applicationand-Session level
variables and start up procedures.
8. Explain the need for user control. How is it created and used?
User controls behaves like a miniature ASP.NET pages and webforms which could be used
by many other pages.
These are derived from the System.Web.UI.UserControl Class. These controls have the
following characteristics:
• They have an .ascx extension.
• They may not contain any <HTML>, <BODY>, or <FORM> Tags.
• They have a Control directive instead of a Page directive.
To understand the concept, let us create a simple user control, which will work as footer for
the web pages. To create and use the user control, take the following steps:
1. Create a new web application.
2. Right click on the project folder on the Solution Explorer and choose Add New Item.
3. Select Web User Control from the Add New Item dialog box and name it footer.ascx.
Initially, the footer.ascx contains only a Control directive. (footer.ascx)
4. To add the user control to your web page, you must add the Register directive and an
instance of the user control to the page.
<%@ Register Src="~/footer.ascx" TagName="footer" TagPrefix="Tfooter" %>
10. Write a short note on List controls in ASP.NET. / What is the difference between
ListBox and Drop Down List? List and explain any three common properties of these
controls.
These controls are used to display the list with some list items in the page. These controls
include List Box, Drop Down List, Check Box List, Radio Button List and Bulleted List.
ListBox: We can select multiple items from ListBox at a time.
Basic syntax of list box control:
DropDownList control is used select single option from multiple listed items.
Basic syntax of DropDown
The CheckBox control allows the user to set true/false or yes/no type options. The user can
select or deselect it. When a check box is selected it has the value True, and when it is
cleared, it holds the value False.
Properties of CheckBox Control:
1. AutoCheck: Gets or sets a value indicating whether the Checked or CheckedState value
and the appearance of the control automatically change when the check box is selected
2. Checked: Gets or sets a value indicating whether the check box is selected.
3. CheckState; Gets or sets the state of a check box.
4. Text: Gets or sets the caption of a check box.
Radio Button List Control is same as Drop Down List but it displays a list of radio buttons
that can be arranged either horizontally or vertically. We can select only one item from the
given Radio Button List of options.
The bulleted list control creates bulleted lists or numbered lists.
In client-side state management, data is stored on the client's browser, making it accessible
across multiple requests without relying on the server.
1. View State: Stores data in a hidden field on a webpage. It maintains the state of the controls
between postbacks within the same page.
2. Control State: Similar to View State but is specifically used to preserve critical information
for controls. Even if View State is disabled, Control State ensures essential data is retained.
3. Hidden Fields: Stores data in HTML hidden input fields that are sent back and forth
between the client and server with each postback. These are not visible to users but can be
accessed via code.
4. Cookies: Small pieces of data stored on the client’s machine. Cookies are commonly used
to store user preferences, session information, or authentication tokens. They have an
expiration date and can persist across sessions.
5. Query Strings: Passes data via the URL. Useful for passing small amounts of data between
pages. However, query strings have size limitations and are visible to users, posing security
risks for sensitive data.
Server-side state management stores data on the server, offering better security and control
but may impact server resources.
1. Application State: Stores data that is shared across all sessions and users of an application.
Useful for storing application-wide data that does not change frequently, such as application
settings.
2. Session State: Stores data unique to each user session. It is maintained throughout the user's
interaction with the application and can be used to track user-specific information like
shopping cart contents.
3. Profile Properties: Allows personalization by storing user-specific information that
persists across sessions. Profile properties are commonly used for data such as user
preferences and settings.
6. How is the connection between the content page and the master page established?
Master page provides a framework (common content as well as the layout) within which
the content from other pages can be displayed. It provides elements such as headers, footers,
style definitions, or navigation bars that are common to all pages in your web site.
So the Content Pages need not have to duplicate code for shared elements within your Web
site.
It gives a consistent look and feel for all pages in your application.
The master page layout consists of regions where the content from each content page should
be displayed. These regions can be set using ContentPlaceHolder server controls.
These are the regions where you are going to have dynamic content in your page
A derived page also known as a content page is simply a collection of blocks the runtime
will use to fill the regions in the master.
To provide content for a ContentPlaceHolder, you use another specialized control, called
Content.
The ContentPlaceHolder control and the Content control have a one-to-one relationship.
For each ContentPlaceHolder in the master page, the content page supplies a matching
Content control
ASP.NET links the Content control to the appropriate ContentPlaceHolder by matching the
ID of the ContentPlaceHolder with the Content ContentPlaceHolderID property of the
corresponding Content control.
2. Explain the ADO .NET architecture. / List and explain ADO.NET objects.
ADO (ActiveX Data Object) is the database access technologies including components for
retrieving data, storing data in memory and binding data to controls.
It is an Object Oriented set of libraries that allows us to interact with data source.
The data source can be a database, text file, Excel spreadsheet or an XML file.
3. What is the use of data source control? Explain the various types of data sources in
ASP.NET. / Write a short note on Data Source controls.
A data source control interacts with the data-bound controls and hides the complex data
binding processes. These are the tools that provide data to the data bound controls and
support execution of operations like insertions, deletions, sorting, and updates.
The data source controls used for hierarchical data are:
XMLDataSource - It allows binding to XML files and strings with or without schema
information.
SiteMapDataSource - It allows binding to a provider that supplies site map information.
The data source controls used for tabular data are:
SqlDataSource: It represents a connection to an ADO.NET data provider that returns
SQL data, including data sources accessible via OLEDB and ODBC.
ObjectDataSource: It allows binding to a custom .Net business object that returns data.
LinqdataSource: It allows binding to the results of a Linq-to-SQL query (supported by
ASP.NET 3.5 only).
AccessDataSource: It represents connection to a Microsoft Access database.
The following table provides the related sets of properties of the SqlDataSource control,
which provides the programming interface of the control:
<script type="text/javascript">
setInterval(function () {
__doPostBack('<%= UpdatePanel1.ClientID %>', '');
}, 5000); // Refresh every 5 seconds
</script>
In the code-behind, update AutoRefreshLabel on each postback:
protected void Page_Load(object sender, EventArgs e)
{
AutoRefreshLabel.Text = "Last updated: " + DateTime.Now.ToString("HH:mm:ss");
}
This script triggers a postback every 5 seconds, refreshing the content within UpdatePanel1.