You are on page 1of 21

Solution Set of AWP solution set November-2018

1. Attempt any three of the following:


a. What is namespace? Explain with the help of an example.

A namespace is designed for providing a way to keep one set of names separate from another.
The class names declared in one namespace does not conflict with the same class names declared
in another.
Defining a Namespace
A namespace definition begins with the keyword namespace followed by the namespace name as
follows −
namespace namespace_name {
// code declarations
}
To call the namespace-enabled version of either function or variable, prepend the namespace
name as follows −
namespace_name.item_name; (2 marks)
Any example demo (3 marks)

b. Explain jagged array with example.


A Jagged array is an array of arrays. You can declare a jagged array named scores of type int as
int [][] scores;

Declaring an array, does not create the array in memory. To create the above array −
int[][] scores = new int[5][];
for (int i = 0; i < scores.Length; i++) {
scores[i] = new int[4];
}

You can initialize a jagged array as −


int[][] scores = new int[2][]{new int[]{92,93,94},new int[]{85,66,87,88}};

Where, scores is an array of two arrays of integers - scores[0] is an array of 3 integers and
scores[1] is an array of 4 integers. (2marks)

Any example (3 marks)

c. What is .NET Framework? Explain its architecture in brief.


The .NET Framework is a new and revolutionary platform created by Microsoft for developing
applications
• It is a platform for application developers
• It is a Framework that supports Multiple Language and Cross languageintegration.
• IT has IDE (Integrated Development Environment).
• Framework is a set of utilities or can say building blocks of your application system.
• .NET Framework provides GUI in a GUI manner.
• .NET is a platform independent but with help of Mono Compilation System (MCS). MCS
is a middle level interface.

Page 1 of 21
• .NET Framework provides interoperability between languages i.e. Common Type System
(CTS) .
• .NET Framework also includes the .NET Common Language Runtime (CLR), which is
responsible for maintaining the execution of all applications developed using the .NET
library.
• The .NET Framework consists primarily of a gigantic library of code. (2 marks)

Components of the .Net Framework with diagram (3 marks)

d. Write a program in C# to demonstrate multiple inheritance using interfaces.


Multiple Inheritance in C#
C# does not support multiple inheritance. However, you can use interfaces to implement multiple
inheritance. The following program demonstrates this −
Any 1 example (5 marks)

e. Explain various Types of Constructors in C#


What is a constructor?
Constructor is a method which gets executed automatically when we create or instantiate object
of that class having constructor.
Types of Constructors in C#
There are 5 types of constructor in C# as listed below
Default Constructor
Parameterized Constructor
Copy Constructor

Page 2 of 21
Static Constructor

Default Constructor
A constructor without any parameters is called as default constructor means a constructor which
does not have any input parameter is known as default constructor.
Example of Default Constructor (1 mark)

Parameterized Constructor
A constructor having one or more parameters is called as parameterized constructor means a
constructor which is having single input parameter or multiple input parameters of same data
types or different data types are known as parameterized constructor.
Example of Parameterized Constructor (1 mark)

Copy Constructor
A constructor that contains a parameter of same class type is called as copy constructor.
C# does not provide a copy constructor. A copy constructor enables you to copy the data stored
in the member variables of an object of the class into another new object means it helps to copy
data stored in one object into another new object of the same instance.
Example of Copy Constructor (1 mark)

Static Constructor
Static constructor should be parameter less means it should not contain any input parameter.
Program will not execute if static constructor is having any input parameter.
Static constructor can be invoked once for any number instances are created and it is invoked
only during the first initialization of instance. It is used to initialize static fields of the class
Static constructor is created using a static keyword as shown below.
Example of Static Constructor (1 mark)

f. What is delegate? Explain multicast delegate with an example.


A delegate is like a pointer to a function. It is a reference type data type and it holds the reference
of a method. All the delegates are implicitly derived from System.Delegate class.
A delegate can be declared using delegate keyword followed by a function signature as shown
below.
Delegate Syntax:
<access modifier> delegate <return type> <delegate_name>(<parameters>) (2 marks)
Multicast Delegate
The delegate can points to multiple methods. A delegate that points multiple methods is called a
multicast delegate. The "+" operator adds a function to the delegate object and the "-" operator
removes an existing function from a delegate object.
Example: Multicast delegate (3 marks)

2. Attempt any three of the following: 15


a. What is the difference between List Box and Drop-Down Lists? List and explain any three
common properties of these controls.

Page 3 of 21
Common properties of list box and drop-down Lists:

Property Description
The collection of ListItem objects that represents the items in the
Items
control. This property returns an object of type ListItemCollection.
Specifies the number of items displayed in the box. If actual list
Rows
contains more rows than displayed then a scroll bar is added.
The index of the currently selected item. If more than one item is
SelectedIndex selected, then the index of the first selected item. If no item is
selected, the value of this property is -1.
The value of the currently selected item. If more than one item is
SelectedValue selected, then the value of the first selected item. If no item is
selected, the value of this property is an empty string ("").
Indicates whether a list box allows single selections or multiple
SelectionMode
selections.
b. Explain Adrotator control with example in ASP.NET

Page 4 of 21
The AdRotator control randomly selects banner graphics from a list, which is specified in an
external XML schedule file. This external XML schedule file is called the advertisement file.

The AdRotator control allows you to specify the advertisement file and the type of window that
the link should follow in the AdvertisementFile and the Target property respectively.

The basic syntax of adding an AdRotator is as follows:

<asp:AdRotator runat = "server" AdvertisementFile = "adfile.xml" Target = "_blank" />


The advertisement file is an XML file, which contains the information about the advertisements
to be displayed. [2 marks]

Any 1 Example of AdRotator Control [3 marks]

c. List and explain any four types of validation controls used in asp.net

ASP.NET validation controls validate the user input data to ensure that useless, unauthenticated,
or contradictory data don't get stored.

ASP.NET provides the following validation controls:

• RequiredFieldValidator
• RangeValidator
• CompareValidator
• RegularExpressionValidator
• CustomValidator
• ValidationSummary [1 mark ]

Explaination of any four controls with syntax and properties or example [1 mark each]

d. Explain Calendar control with example in ASP.NET


The calendar control is a functionally rich web control, which provides the following capabilities:

• Displaying one month at a time


• Selecting a day, a week or a month
• Selecting a range of days
• Moving from month to month
• Controlling the display of the days programmatically

The basic syntax of a calendar control is:

<asp:Calender ID = "Calendar1" runat = "server">


</asp:Calender> [1 mark]

Any 1 example [4 marks]

Page 5 of 21
e. Short note on Page class.

f. Explain SiteMapPath control in ASP.NET

• The SiteMapPath control basically is used to access web pages of the website from one
webpage to another. It is a navigation control and displays the map of the site related to
its web pages.

• This map includes the pages in the particular website and displays the name of those
pages. We can click on that particular page in the Site Map to navigate to that page. We
can say that the SiteMapPath control displays links for connecting to URLs of other
pages.

• The SiteMapPath control uses a property called SiteMapProvider for accessing data from
databases and it stores the information in a data source. [1 mark ]

Any 1 example or Syntax and Properties description [4 marks]

3. Attempt any three of the following: 15


a. What is user-defined exception? Explain with example.
We have seen built-in exception classes however, we often like to raise an exception when the
business rule of our application gets violated. So, for this we can create a custom exception class
by deriving Exception or ApplicationException class. [1 mark]

Page 6 of 21
Any 1 example [4 marks]

b. What is debugging. Explain the process of debugging in detail.


Debugging allows the developers to see how the code works in a step-by-step manner, how the
values of the variables change, how the objects are created and destroyed, etc.

When the site is executed for the first time, Visual Studio displays a prompt asking whether it
should be enabled for debugging:

When debugging is enabled, the following lines of codes are shown in the web.config:

<system.web>
<compilation debug="true">
<assemblies>
..............
</assemblies>
</compilation>
</system.web>
The Debug toolbar provides all the tools available for debugging:

Breakpoints

Breakpoints specifies the runtime to run a specific line of code and then stop execution so that
the code could be examined and perform various debugging jobs such as, changing the value of
the variables, step through the codes, moving in and out of functions and methods etc.

To set a breakpoint, right click on the code and choose insert break point. A red dot appears on
the left margin and the line of code is highlighted as shown:

Next when you execute the code, you can observe its behavior.

At this stage, you can step through the code, observe the execution flow and examine the value of
the variables, properties, objects, etc.

You can modify the properties of the breakpoint from the Properties menu obtained by right
clicking the breakpoint glyph:

The location dialog box shows the location of the file, line number and the character number of
the selected code. The condition menu item allows you to enter a valid expression, which is
evaluated when the program execution reaches the breakpoint:

The Hit Count menu item displays a dialog box that shows the number of times the break point
has been executed.

Page 7 of 21
Clicking on any option presented by the drop down list opens an edit field where a target hit
count is entered. This is particularly helpful in analyzing loop constructs in code.

The Filter menu item allows setting a filter for specifying machines, processes, or threads or any
combination, for which the breakpoint will be effective.

The When Hit menu item allows you to specify what to do when the break point is hit.

The Debug Windows

Visual Studio provides the following debug windows, each of which shows some program
information. The following table lists the windows:

Window Description
Immediate Displays variables and expressions.
Autos Displays all variables in the current and previous statements.
Locals Displays all variables in the current context.
Watch Displays up to four different sets of variables.
Call Stack Displays all methods in the call stack.
Threads Displays and control threads.
c. Write short note on cookies in ASP.NET.
Cookies is a small piece of information stored on the client machine. This file is located on client
machines "C:\Document and Settings\Currently_Login user\Cookie" path. Its is used to store
user preference information like Username, Password,City and PhoneNo etc on client machines.
We need to import namespace called Systen.Web.HttpCookie before we use cookie.

Type of Cookies?

1. Persist Cookie - A cookie has not have expired time Which is called as Persist Cookie
2. Non-Persist Cookie - A cookie has expired time Which is called as Non-Persist Cookie

How to create a cookie?

Its really easy to create a cookie in the Asp.Net with help of Response object or HttpCookie

Example 1:

HttpCookie userInfo = new HttpCookie("userInfo");


userInfo["UserName"] = "Annathurai";
userInfo["UserColor"] = "Black";
userInfo.Expires.Add(new TimeSpan(0, 1, 0));
Response.Cookies.Add(userInfo);

Example 2:

Page 8 of 21
Response.Cookies["userName"].Value = "Annathurai";
Response.Cookies["userColor"].Value = "Black";

How to retrieve from cookie?

Its easy way to retrieve cookie value form cookes by help of Request object.

Example 1:

string User_Name = string.Empty;


string User_Color = string.Empty;
User_Name = Request.Cookies["userName"].Value;
User_Color = Request.Cookies["userColor"].Value;

Example 2:

string User_name = string.Empty;


string User_color = string.Empty;
HttpCookie reqCookies = Request.Cookies["userInfo"];
if (reqCookies != null)
{
User_name = reqCookies["UserName"].ToString();
User_color = reqCookies["UserColor"].ToString();
}

When we make request from client to web server , the web server process the request and give
the lot of information with big pockets which will have Header information, Metadata, cookies
etc., Then repose object can do all the things with browser.

Cookie's common property:

1. Domain => Which is used to associate cookies to domain.


2. Secure => We can enable secure cookie to set true(HTTPs).
3. Value => We can manipulate individual cookie.
4. Values => We can manipulate cookies with key/value pair.
5. Expires => Which is used to set expire date for the cookies.

Advantages of Cookie:

1. Its clear text so user can able to read it.


2. We can store user preference information on the client machine.
3. Its easy way to maintain.
4. Fast accessing.

Page 9 of 21
Disadvantages of Cookie

1. If user clear cookie information we can't get it back.


2. No security.
3. Each request will have cookie information with page.

How to clear the cookie information?

1. we can clear cookie information from client machine on cookie folder


2. To set expires to cookie object
userInfo.Expires = DateTime.Now.AddHours(1);
It will clear the cookie with one hour duration.

d. What is ViewState in ASP.NET? State its Advantages and Disadvantages.


View State is one of the most important and useful client side state management mechanism. It
can store the page value at the time of post back (Sending and Receiving information from
Server) of your page. ASP.NET pages provide the ViewState property as a built-in structure for
automatically storing values between multiple requests for the same page.

Example:

If you want to add one variable in View State,

Hide Copy Code


ViewState["Var"]=Count;
For Retrieving information from View State

Hide Copy Code


string Test=ViewState["TestVal"];
Sometimes you may need to typecast ViewState Value to retreive. As I give an Example to strore
and retreive object in view state in the last of this article.

Advantages of view state

This are the main advantage of using View State:

• Easy to implement
• No server resources are required
• Enhanced security features ,like it can be encoded and compressed.

Disadvantages of view state

This are the main disadvantages of using View State:

Page 10 of 21
• It can be performance overhead if we are going to store larger amount of data , because it
is associated with page only.
• Its stored in a hidden filed in hashed format (which I have discussed later) still it can be
easily trapped.
• It does not have any support on mobile devices.

When we should use view state

I already describe the criteria of selecting State management. A few point you should remember
when you select view state for maintain your page state.

• Size of data should be small , because data are bind with page controls , so for larger
amount of data it can be cause of performance overhead.
• Try to avoid storing secure data in view state

When we should avoid view state

You won't need view state for a control for following cases,

• The control never change


• The control is repopulated on every postback
• The control is an input control and it changes only of user actions.

e. Create a web application to demonstrate use of Master Page with applying Styles and
Themes for page beautification. Write necessary steps with code for the same.

Any 1 example with MasterPage.Master, MasterDisplay.aspx and StyleSheet.css

f. Explain the four most important selectors present in CSS.


Universal Selector
The Universal selector, indicated by an asterisk (*), applies to all elements in your page. The
Universal selector can be used to set global settings like a font family. The following rule set
changes the font for all elements in our page to Arial:
*{
font-family: Arial;
}
Type Selector
The Type selector enables us to point to an HTML element of a specific type. With a Type
selector all HTML elements of that type will be styled accordingly.
h1
{
color: Green;

Page 11 of 21
}
This Type selector now applies to all <h1> elements in your code and gives them a green color.
Type
Selectors are not case sensitive, so you can use both h1 and H1 to refer to the same heading.
ID Selector
The ID selector is always prefixed by a hash symbol (#) and enables us to refer to a single
element in the page. Within an HTML or ASPX page, we can give an element a unique ID using
the id attribute. With the ID selector, we can change the behavior for that single element, for
example:
#IntroText
{
font-style: italic;
}
Because we can reuse this ID across multiple pages in our site (it only must be unique within a
single page), you can use this rule to quickly change the appearance of an element that you use
once per page, but more than once in our site, for example with the following HTML code:
<p id=”IntroText”>I am italic because I have the right ID. </p>
Class Selector
The Class selector enables us to style multiple HTML elements through the class attribute. This
is handy when we want to give the same type of formatting to several unrelated HTML elements.
The following rule changes the text to red and bold for all HTML elements that have their class
attributes set to highlight:
.Highlight
{
font-weight: bold;
color: Red;
}
The following code snippet uses the Highlight class to make the contents of a <span> element
and a link (<a>) appear with a bold typeface:
This is normal text but <span class=”Highlight”>this is Red and Bold.</span>
This is also normal text but
<a href=”CssDemo.aspx” class=”Highlight”>this link is Red and Bold as well.</a>
4. Attempt any three of the following: 15
a List and Explain ADO.NET objects.
ADO.NET includes many objects we can use to work with data. Some important objects of
ADO.NET are:
Connection
To interact with a database, we must have a connection to it. The connection helps identify the
database server, the database name, user name, password, and other parameters that are required
for connecting to the data base.
A connection object is used by command objects so they will know which database to execute
the command on.
Command
The command object is one of the basic components of ADO .NET. The Command Object uses
the connection object to execute SQL queries.

Page 12 of 21
The queries can be in the Form of Inline text, Stored Procedures or direct Table access. An
important feature of Command object is that it can be used to execute queries and Stored
Procedures with Parameters If a select query is issued, the result set it returns is usually stored in
either a DataSet or a DataReader object.
DataReader
Many data operations require that we only get a stream of data for reading. The data reader object
allows us to obtain the results of a SELECT statement from a command object. For performance
reasons, the data returned from a data reader is a fast forward-only stream of data.
This means that we can only pull the data from the stream in a sequential manner this is good for
speed, but if we need to manipulate data, then a DataSet is a better object to work with.
DataSet
DataSet objects are in-memory representations of data. They contain multiple Datatable objects,
which contain columns and rows, just like normal database tables. We can even define relations
between tables to create parent-child relationships.
The DataSet is specifically designed to help manage data in memory and to support disconnected
operations on data, when such a scenario make sense.
DataAdapter
The data adapter fills a DataSet object when reading the data and writes in a single batch when
persisting changes back to the database. A data adapter contains a reference to the connection
object and opens and closes the connection automatically when reading from or writing to the
database.
b What is DataReader in ADO.NET? Explain with example.
DataReader provides an easy way for the programmer to read data from a database as if it were
coming from a stream. The DataReader is the solution for forward streaming data through
ADO.NET.
DataReader is also called a firehose cursor or forward read-only cursor because it moves forward
through the data. The DataReader not only allows us to move forward through each record of
database, but it also enables us to parse the data from each column. The DataReader class
represents a data reader in ADO.NET. [1 mark]
Any 1 example [4 marks]

c Explain SqlDataSource in ADO.NET.


The SqlDataSource control represents a connection to a relational database such as SQL Server
or Oracle database, or data accessible through OLEDB or Open Database Connectivity (ODBC).
Connection to data is made through two important properties ConnectionString and
ProviderName.
The following code snippet provides the basic syntax of the control:
<asp:SqlDataSource runat="server" ID="MySqlSource"
ConnectionString='<%$ ConnectionStrings:Empconstr %>'
SelectionCommand= "SELECT * FROM EMPLOYEES" />
The following table provides the related sets of properties of the SqlDataSource control, which
provides the programming interface of the control:
The following code snippet shows a data source control enabled for data manipulation:
<asp:SqlDataSource runat="server" ID= "MySqlSource"
ConnectionString=' <%$ ConnectionStrings:Empconstr %>'
SelectCommand= "SELECT * FROM EMPLOYEES"

Page 13 of 21
UpdateCommand= "UPDATE EMPLOYEES SET LASTNAME=@lame"
DeleteCommand= "DELETE FROM EMPLOYEES WHERE EMPLOYEEID=@eid"
FilterExpression= "EMPLOYEEID > 10">
.....
.....
</asp:SqlDataSource>
d What is a GridView control? Explain with an example.
The GridView control displays the values of a data source in a table. Each column represents a
field, while each row represents a record. The GridView control supports the following features:
Binding to data source controls, such as SqlDataSource.
Built-in sort capabilities.
Built-in update and delete capabilities.
Built-in paging capabilities.
Built-in row selection capabilities.
Multiple key fields.
Multiple data fields for the hyperlink columns.
Customizable appearance through themes and styles

Sorting allows the user to sort the items in the GridView control with respect to a specific
column by clicking on the column's header. To enable sorting, set the AllowSorting property to
true.
AllowSorting="True"
Instead of displaying all the records in the data source at the same time, the GridView control can
automatically break the records up into pages. To enable paging, set the AllowPaging property to
true.
AllowPaging="True"
Also we can set how many rows we want to see in a page.
PageSize="4"

Example:
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT * FROM Customers"))
{
cmd.Connection = con;
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}

Page 14 of 21
e What is the application services provided in ASP.NET? Explain.
ASP.NET application services are built-in Web services that provide access to features such as
forms authentication, roles, and profile properties. These services are part of a service-oriented
architecture (SOA), in which an application consists of one or more services provided on the
server, and one or more clients. For more information about SOA, see Understanding Service-
Oriented Architecture on the MSDN Web site.

An important feature of ASP.NET application services is that they are available to a variety of
client applications, not just ASP.NET Web applications. ASP.NET application services are
available to any client that is based on the .NET Framework. In addition, any client application
that can send and receive messages in SOAP format can use ASP.NET application services.

This topic contains the following information.

• Scenarios
• Background
• Examples
• Class Reference
• Additional Resources

Scenarios

Client applications for ASP.NET application services can be of different types and can run on
different operating systems. These include these following types of clients:

• AJAX clients. These are ASP.NET Web pages (.aspx files) that run in the browser and
that access application services from client script. AJAX clients typically use JSON
format to exchange data. For more information, see Using Web Services in ASP.NET
AJAX.
• .NET Framework clients. These are .NET Framework Windows applications that access
application services over HTTP by using the provider model infrastructure, and that use
JSON protocol to exchange data. For more information, see Client Application Services
Overview.

Note

The provider model adapts the membership system to use different data stores, or data
stores with different schemas. For more information, see Membership Providers.
• SOAP clients. These are clients that can access application services through SOAP 1.1.
This is useful for clients that are running on other operating systems or using other
technologies, such as Java applications. For more information, see Walkthrough: Using
ASP.NET Application Services.

The following illustration shows how different clients communicate with the services.

Page 15 of 21
Web Services communication

Background

The application services provided by ASP.NET enable client applications to access and share
information that is part of a Web application. ASP.NET makes available the following
application services:

• Authentication service. This service enables you to let users log onto an application. The
service accepts user credentials and returns an authentication ticket (cookie). For more
information, see ASP.NET Forms Authentication Overview.
• Roles service. This service determines the application-related roles for an authenticated
user, based on information that is made available by an ASP.NET roles provider. This can
be useful if you want to provide specific UI or enable access to specific resources,
depending on the user's role. For more information, see Managing Authorization Using
Roles.
• Profile service. This service provides per-user information as a user profile that is stored
on the server. This enables your application to access a user's settings at different times
and from different client UI components. For more information, see ASP.NET Profile
Properties Overview.

Application Service Clients


This section provides details about the types of client applications that can use ASP.NET
application services and some information about how the client communicates with an
application service.

AJAX Clients
AJAX clients (AJAX-enabled ASP.NET Web pages) exchange data with application services
over HTTP by using POST requests. The data is packaged in JSON format. The client
application communicates with the application services through client-script proxy classes. The
proxy classes are generated by the server and downloaded to the browser as part of any page that
calls an application service. For more information, see ASP.NET Web Services in AJAX.

Page 16 of 21
.NET Framework Clients
ASP.NET application services exchange data with .NET Framework clients over HTTP by using
POST requests. The data is packaged in JSON format. The client application communicates with
the application services by using the .NET Framework provider model. For ASP.NET application
services, the provider model refers to the .NET Framework client types and the related
membership providers that store and retrieve user's credentials from a data source. For example,
this includes the SqlMembershipProvider class.

The communication between client and server is synchronous. For more information, see Client
Application Services Overview. The application services are implemented by the types that are
defined in the System.Web.ClientServices.Providers namespace.

To access an application service, a .NET Framework client application must be configured


appropriately. The server configuration is the same as the one used for the application services in
AJAX.

For more information about the provider model, see ASP.NET 2.0 Provider Model: Introduction
to the Provider Model and Introduction to Membership.

SOAP Clients
You can access ASP.NET authentication, profile, and roles services from any client application
on any operating system that can use SOAP 1.1 protocol. ASP.NET application services are built
on the Windows Communication Foundation (WCF) and exchange data with the client in SOAP
format. For more information, see XML Web Services Infrastructure on the MSDN Web site.

Communication between the client and the application services is performed by using proxy
classes that run in the client and that represent the application service. You can generate proxy
classes that support ASP.NET application services by using the Service Model Metadata Utility
Tool (svcutil.exe) tool. For more information, see Walkthrough: Using ASP.NET Application
Services.

The following proxy classes are supported:

• Authentication service client. The generated authentication-service client proxy class


enables you to use the authentication service from any client application that can send and
read SOAP messages. Users of an ASP.NET application and of an application that does
not use the .NET Framework can authenticate by using the same user credentials.
Authentication tickets that are issued by the service are created as HTTP cookies and are
compatible with ASP.NET forms authentication. For more information, see How to:
Enable the WCF Authentication Service. For more information about authentication
tickets, see FormsAuthenticationTicket.

f Differentiate between FormView and DetailsView.


• The DetailsView control is easier to work with.
• The FormView control provides more control over the layout.

Page 17 of 21
• The FormView control uses only the templates with databinding expressions to display
data. The DetailsView control uses <BoundField> elements or <TemplateField>
elements.
• The FormView control renders all fields in a single table row whereas the DetailsView
control displays each field as a table row.

Note : The above points must be explained in details with the help of simple example.

5. Attempt any three of the following: 15


a. Explain XmlTextReader and XmlTextWriter with an example.
Reading the XML document in our code is just as easy with the corresponding XmlTextReader
class. The XmlTextReader moves through our document from top to bottom, one node at a time.

XmlTextWriter is one of many useful classes in System.Xml namespace, and it provides several
useful methods to write a complete XML Document from scratch.
Following form is simple ASP.NET web form asking user to input some data about the product. I
will save this data in a separate XML document named Product.xml using XmlTextWriter object.
[2 marks]

Any 1 example [3 marks]

b. Explain XElement class with an example.

The XElement class is one of the fundamental classes in LINQ to XML. It represents an XML
element. You can use this class to create elements; change the content of the element; add,
change, or delete child elements; add attributes to an element; or serialize the contents of an
element in text form. You can also interoperate with other classes in System.Xml, such as
XmlReader, XmlWriter, and XslCompiledTransform. [1 mark]
Any 1 example of XElement is expected. [4 marks]

c. What do you mean by authentication? Explain its types.


Authentication : It is the process of ensuring the user's identity and authenticity. ASP.NET allows
three types of authentications:

• Windows Authentication
• Forms Authentication
• Windows LiveID Authentication

Windows-based authentication:
It causes the browser to display a login dialog box when the user attempts to access restricted
page.
It is supported by most browsers.
It is configured through the IIS management console.
It uses windows user accounts and directory rights to grant access to restricted pages.

Page 18 of 21
Forms-based authentication:
Developer codes a login form that gets the user name and password.
The username and password entered by user are encrypted if the login page uses a secure
connection.
It doesn’t reply on windows user account.

Windows Live ID authentication:


It is centralized authentication service offered by Microsoft.
The advantage is that the user only has one maintain one username and password.

d. What do you mean by Impersonation in ASP.NET? Explain.


When using impersonation, ASP.NET applications can execute with the Windows identity (user
account) of the user making the request. Impersonation is commonly used in applications that
rely on Microsoft Internet Information Services (IIS) to authenticate the user.

ASP.NET impersonation is disabled by default. If impersonation is enabled for an ASP.NET


application, that application runs in the context of the identity whose access token IIS passes to
ASP.NET. That token can be either an authenticated user token, such as a token for a logged-in
Windows user, or the token that IIS provides for anonymous users (typically, the
IUSR_MACHINENAME identity).

When impersonation is enabled, only your application code runs under the context of the
impersonated user. Applications are compiled and configuration information is loaded using the
identity of the ASP.NET process.

Impersonate the IIS Authenticated Account or User


Impersonate a Specific User for All the Requests of an ASP.NET Application
Impersonate the Authenticating User in Code
Impersonate a Specific User in Code

e. Explain ASP.NET AJAX Control Toolkit.


The ASP.NET AJAX Control Toolkit is an open-source project built on top of the Microsoft
ASP.NET AJAX framework. It is a joint effort between Microsoft and the ASP.NET AJAX
community that provides a powerful infrastructure to write reusable, customizable and extensible
ASP.NET AJAX extenders and controls, as well as a rich array of controls that can be used out of
the box to create an interactive Web experience.

The AJAX Control Toolkit contains more than 30 controls that enable you to easily create rich,
interactive web pages.

The ASP.Net AJAX Control toolkit is now maintained by DevExpress Team. The Current
Version of ASP.Net AJAX Toolkit is v16.1.0.0. There are lot of new enhancement in the current
version from new controls to bug fixes in all controls.
The ASP.NET AJAX Control Toolkit has a lot going for it:
It’s completely free.

Page 19 of 21
It includes full source code, which is helpful if we’re ambitious enough to want to create our own
custom controls that use ASP.NET AJAX features.
It uses extenders that enhance the standard ASP.NET web controls. That way, we don’t have to
replace all the controls on our web pages.

f. Create a web application to demonstrate the use of HTMLEditorExtender Ajax Control.


Write the code of default.aspx and required property settings for the same.

HTLEditorExtender Ajax control example


1. Add the Script Manager Control on your page
2. Add a TextBox (columns = 80, rows =20 textmode = multiline)
3. Select that textbox control
4. Now add HtmlEditorExtender control from AJAX control toolkit.
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"


tagprefix="ajaxToolkit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:ScriptManager ID="ScriptManager1" runat="server">


</asp:ScriptManager>

<asp:TextBox ID="TextBox1" runat="server" Columns="80" Rows="20"


TextMode="MultiLine"></asp:TextBox>
<ajaxToolkit:HtmlEditorExtender ID="TextBox1_HtmlEditorExtender" runat="server"
TargetControlID="TextBox1" EnableSanitization="false">
<Toolbar>
<ajaxToolkit:Undo /> <ajaxToolkit:Redo />
<ajaxToolkit:Bold /><ajaxToolkit:Italic />
<ajaxToolkit:SelectAll /><ajaxToolkit:UnSelect />
<ajaxToolkit:Delete />
<ajaxToolkit:Copy />
<ajaxToolkit:Paste />
<ajaxToolkit:Cut />

Page 20 of 21
</Toolbar>
</ajaxToolkit:HtmlEditorExtender>
</div>

Page 21 of 21

You might also like