Interview Questions and Answers, Frequently Asked Questions (FAQs) and Useful Articles

Home  >> Interview Questions and Answers  >> Microsoft .NET Technologies  >> ASP.NET 2.0 Interview Questions and Answers

Interview Questions & Answers

ASP.NET 2.0 Interview Questions and Answers

This page contains the collection of ASP.NET 2.0 Interview Questions and Answers / Frequently Asked Questions (FAQs) under category Microsoft .NET Technologies. These questions are collected from various resources like informative websites, forums, blogs, discussion boards including MSDN and Wikipedia. These listed questions can surely help in preparing for ASP.NET 2.0 interview or job.

<< Previous Page 1 Page 2

What r the ASP.NET list controls and diff. between them?
ASP.NET List controls ==> There are 3 . 1. DropDownList, 2. ListBox and 3.HTMLSelect.1. System.Web.UI.WebControls.DropDownListthis control renders a drop-down list in the page at runtime. Only the selected item is visible when the user is not interacting with the list, and the other items become visible when the user clicks the control to see the items that can be selected. Only one item can be selected in this control. This control must be inserted into a server side form (runat="server") applied.2. System.Web.UI.WebControls.ListBoxthis control renders a list of items within a scrolling box, multiple items can be selected in this control if required. This control must be inserted into a server side form (runat="server") applied.3. System.Web.UI.HTMLControls.HTMLSelectthis control can be used to render a drop-down list or a scrolling list of items. This control has less built in functionality when compared with controls above (It lacks many of the properties that can be used to influence the display style such as ForeColor and BackColor to name a couple) ,but it is still capable of performing most common uses of a list control. This control can be inserted anywhere, and does not require a server side form.

What is versioning in .NET?
Different versions of a same component can run in one computer.we can achieve it by registering the assembly in the global assembly cache.

How does u call and execute a SP in .NET?
Public DataSet SampleToExecute_SP_IN_DOTNET() { DataSet DataSetHome = new DataSet(); SqlConnection SqlConnectionHome=new SqlConnection(strConnectionString); SqlCommand SqlCommandHome=new SqlCommand(); SqlCommandHome.Connection = SqlConnectionHomeReportCheck; SqlCommandHome.CommandText = "CLM_getCurYearStatistics"; SqlCommandHome.CommandType = CommandType.StoredProcedure; SqlDataAdapter DataAdapterHome = new SqlDataAdapter(SqlCommandHome); try { DataAdapterHome.Fill (DataSetHome); return DataSetHome; } catch(SqlException ex) { throw(ex); } catch(Exception ex) { throw(ex); } finally { DataAdapterHome.Dispose (); SqlCommandHome.Dispose(); SqlConnectionHome.Close(); } }

Explain Why Datareader is useful?
Data Reader is Read only version Data Set,Each record is returned as a Data Reader Object,ExecuteReader method acts directly on the database connection.

There are two versions of the data reader object:

OleDbDataReader and SqlDataReader.

Data reader is used to fetch the records from database in read only and forward.

What are ASP.NET Web Forms? How is this technology different than what is available though ASP (1.0-3.0)?
ASP .NET Web form is a tool used to design a web page using the drag and drop feature in VS .NET and is similar to the 'Form' tool in Visual Studio 5.0/6.0. It functions like the Form tag in classic ASP to get or post data from or to the server.

The difference between a classic ASP page and an ASP web Form is as follows:-

A classic ASP has the extension .asp.

An ASP.NET web form has the extension .aspx


A classic ASP page can be created using a Text editor or programs like DreamWeaver.

An ASP .NET web form is created in a project in the VS.NET environment.


The source of a classic ASP is in VBScript or JavaScript and is visible to the end user.

The source of an ASP.NET web form is written in the code behind file ex: .cs for C# or .vb for and is invisible to the end user.


An ASP.NET Web form is Event driven.

How does VB.NET/C# achieve polymorphism?
Using Function Overloading and Function Overriding we can achieve polymorphism in .net

How would you implement inheritance using VB.NET/C#?
In VB - Inherits

In C# - Colon (:)

Explain What is an assembly?
Assembly is a collection of code files , types and resources. It is a unit of deployment,version cotrol and reuse.Assembly is basically collection of exe or dll files which are generated upon successfull compilation of the .Net application

What is .NET remoting?
.NET remoting provides a framework that allows objects to interact with one another across application domains. The framework provides a number of services, including activation and lifetime support, as well as communication channels responsible for transporting messages to and from remote applications.for further info refer MSDN

Explain Diff between Dataset and Datareader?
Dataset is used to store the data, it contains collections of Datatable.

Datareader is used to connect to the database for retrieving data.

Explain Diff. betn Dataset and Recordset?
DataSet can be considered as a logical database as it has the capability to store more than one table and have relations maintained between the tables as in a relational database. Where as a RecordSet can hold only one table at a time.

What is the root namespace for all types?
System is the root of al the namespace in .net

In order to get assembly info whcih namespace we should import?

Can you edit data in the Repeater control?
A Repeater control is a light weight control which can be used for simple reporting purposes. It supports basic event-handling like Init, Load, Unload etc., This also supports some basic formatting of data and can be presented to the user. A Repeater control offers limited level of data editing or selecting capabilities. For such editing and updates ASP .Net offers DataList and DataGrid controls.

What method do you use to explicitly kill a user s session?
session.abandon-to kill all

session.remove-to spec item

Explain What is an abstract class?
An abstract class is one in which methods are defined but an object of this class cannot be instanstiated.this type of a class can only be derived but cannot be instantiated.

Can you give an example of when it would be appropriate to use a web service as opposed to a non-serviced .NET component?
If you are developing an intranet app and you want to display the current stock price of your company, its best to consume a webservice the provide that service. IOW, when you want to get 'outside' data throuh a corporate firewall

If, say, you want to display latest news from HR deartment in your portal, better to have a .NET DLL that connect to corporate HR Database and get the info.

Trace and Debug belongs to which namespaces?

Lets say I have an existing application written using Visual Studio 6 (VB 6, InterDev 6) and this application utilizes Windows 2000 COM+ transaction services. How would you approach migrating this application to .NET?
COM components are accessed from the .NET runtime via a Runtime Callable Wrapper (RCW). This wrapper turns the COM interfaces exposed by the COM component into .NET-compatible interfaces

Explain DIff. between Friend and Protected Friend?
Friend access provides access to member with in the namespaces .The protected friend gives specifies access to the member with in the namespace and the derving classes.

How do u declare static variable and how it is declared and what is its lifetime?
By using keyword static before the variable name. Static variable retains the same data throughout the execution of a program.

How does u get record no from 5 to 15 from a dataset of 100 records?
// ds-> daata set

//dr as datarow

for i=5 to 15




You can also archive using this syntax. sqlconnection con=new sqlconnection(""); Sqldataadapter da=new Sqldataadapter("T-SQlQUARy",con); dataset ds=new dataset(); da.Fill(ds,5,15,"tablename");

Which namespace is used to get assembly details?
System.Assembly is the namespace which u need to include in u r program to get the assemply details.To get the assemply details of the current running one is thru reflection so u need another namespace calledSystem.Reflection "Happy Programming"

What is CLR? Diff between CLR & CTS?
CLR is the Common Language Runtime for the dotnet frame work.
CTS is the Common Type Sytem for all languages.It consists of the types(Class,Enums,Structs,Interfaces etc for any language)

CTS is one of the component of CLR.

CLR is the Runtime Engine which provide services to execute the application.CTS is part of CLR

What is DLL hell?
Previously, before .NET, this used to be a major issue. "DLL Hell" refers to the set of problems caused when multiple applications attempt to share a common component like a dynamic link library (DLL) or a Component Object Model (COM) class. In the most typical case, one application will install a new version of the shared component that is not backward compatible with the version already on the machine. Although the application that has just been installed works well, existing applications that depended on a previous version of the shared component might no longer work. In some cases, the cause of the problem is even more subtle. In many cases there is a significant delay before a user discovers that an application has stopped working. As a result, it is often difficult to remember when a change was made to the machine that could have affected the application. A user may remember installing something a week ago, but there is no obvious correlation between that installation and the behavior they are now seeing. The reason for these issues is that version information about the different components of an application aren't recorded or enforced by the system. Also, changes made to the system on behalf of one application will typically affect all applications on the machine.

What is diff. between abstract class and an interface?
What is shadowing?
Diff between Overriding and overloading?

An abstract class and Interface both have method only but not have body of method.The difference between Abstract class and An Interface is that if u call Ablstract class then u have to call all method of that particular Abstract class but if u call an Interface then it is not necessary that u call all method of that particular interface.Method OverLoading:-Return type, Parameter type, parameter and body of method number may be different.Method Overriding:- Return type, Parameter type, Parameter Number all must be same . Only body of method can change.

How to create a DB connection at one place/page so that we can use that connection for all pages/forms/windows.what r the steps ned to be performed.
if question not clear,let me know.

<?xml version="1.0" encoding="utf-8" ?>
<!-- Web.Config Configuration File -->
<add key="ConnectionString"
value="server=localhost;database=Northwind;uid=sa;password=secret;" />
<customErrors mode="Off"/>

Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration

Public Class ConnString : Inherits Page

Protected dataGrid As DataGrid

Protected Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
Dim sqlConn As SqlConnection
Dim sqlCmd As SqlCommand
Dim strConnection As String

'Get connection string from Web.Config
strConnection = ConfigurationSettings.AppSettings("ConnectionString")
sqlConn = New SqlConnection(strConnection)
sqlCmd = New SqlCommand("SELECT * FROM Customers WHERE " _
& "(CompanyName LIKE 'A%') OR (CompanyName LIKE 'B%')", sqlConn)
dataGrid.DataSource = sqlCmd.ExecuteReader()
Catch ex As Exception
Response.Write(ex.ToString & "<br>")
End Try
End Sub

End Class

What is IPostBack? How to use it?
Gets a value indicating whether the page is being loaded in response to a client postback, or if it is being loaded and accessed for the first time.
Property Value

true if the page is being loaded in response to a client postback; otherwise, false.

void Page_Load() {
if (!IsPostBack) {
// Validate initially to force asterisks
// to appear before the first roundtrip.

What is server infrastructure & Server components?
Component product of Windows Server System is effective on its own, as individual components and as part of an integrated system. To provide a framework for Windows Server System product improvement, Starting with the infrastructure server product releases for 2005, with a vision of delivering a common set of services across all Windows Server System products.

All Windows Server System products will provide infrastructure built on the Volume Shadow Copy Service to support fast backup and recovery of data. Each Windows Server System product team will develop a Volume Shadow Copy Service writer. Volume Shadow Copy Service is a framework for facilitating communication among applications, storage subsystems, and storage management applications (including backup applications) to define, persist, and exploit point-in-time copies of storage data.

This infrastructure will provide backup/restore to product solution providers to reduce their cost of product development
and enable IT administrators to provide their organizations with fast backup and recovery of data at reduced costs.

Explain What is event bubbling?
Event Bubbling is nothing but events raised by child controls is handled by the parent control. Example: Suppose consider datagrid as parent control in which there are several child controls.There can be a column of link buttons right.Each link button has click event.Instead of writing event routine for each link button write one routine for parent which will handlde the click events of the child link button events.Parent can know which child actaully triggered the event.That thru arguments passed to event routine. " Happy programming"

Which dll handles the request of .aspx page?
When the Internet Information Service process (inetinfo.exe) receives an HTTP request, it uses the filename extension of the requested resource to determine which Internet Server Application Programming Interface (ISAPI) program to run to process the request. When the request is for an ASP.NET page (.aspx file), IIS passes the request to the ISAPI DLL capable of handling the request for ASP.NET pages, which is aspnet_isapi.dll.

How to reduce the width of textbox in EditCommandColumn of DataGrid?
convert textbox column into a template then it lets you change its width

If we remove web.config or machine.config from the application then, Is this application will works?
If we remove the web.config file from the application it will work.

unless it doesnt have the things like connectionstring etc.

List of Words of PreProcessor in .NET?
Main use of directives

Please brief not about XSD,XSLT & XML?
XSD stands for XML Schema Definition.It define the structure of the XML file and the elements and attributes it contains.The datatype of the elements.So that when u populate XML data into dataset, the dataset can treat elements differently based on their type.If XSD is not present dataset treats all elements as string type. XSLT stands for XML style sheet lang tranformation.It is lang used for transforming XML data in one format to another format.Example XML data into HTML format. XSLT uses XPath to identify the elements in XML doc and transform those to desired format

What is PreProcessor in .NET and type, where it use?
The pre-processing directives provide the ability to conditionally skip sections of source files, to report error and warning conditions, and to delineate distinct regions of source code. The term "pre-processing directives" is used only for consistency with the C and C++ programming languages. In C#, there is no separate pre-processing step; pre-processing directives are processed as part of the lexical analysis phase.
A preprocessor directive must be the only instruction on a line. Preprocessing directives are lines in your program that start with `#'. Whitespace is allowed before and after the `#'. The `#' is followed by an identifier that is the directive name. For example, `#define' is the directive
Types are:
#if, #else, #elif, #endif, #define, #undef, #warning, #error, #line, #region, #endregion

They are used for:
Conditional compilation
Line control
Error and Warning reporting

For example u can refere the MS site ...

What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?
Server.Transfer is used when redirecting the webpage with in the same applicationwhereasResponse.Redirect is applicabletowards the redirection of webpage between 2 applications

Response.Redirect will instruct browser to call a particular webpage.This will increase one request and one response between the client and server.

ColumnMapping belongs to which namespaces?
ColumnMapping belongs to which namespaces

Name some ASP Objects?
1. Session Object

2. Application Object

3. Server Object

4. Request Object

5. Response Object

6. Object Context

7. Error Object

What types of data validation events are commonly seen in the client-side form validation?
Required Field Validator

Requried Filed Validator,Compare filed validator

In A Page I have gridview with Options of select and delete using hyperlink when i am selecting any one of then it has to open another page how can it?
You can have template column for select and delete instead of the databound column. In which you can mention the destination page where you need to navigate.

Using RowDataBound event, you can add attribute to the select and delete hyperlink like:

e.Row.Cells(CellPosition).Controls(0).Attributes.Add("OnClick","return fnJavascriptFunction()")

e.Row.Cells(CellPosition).Controls(0).Attributes.Add("OnClick","return fnJavascriptFunction('"& If any argument &"')").

Web service support

a) Data set
b) dataReader
c) both of above
d) none of above

a) Data Set

Web service support Data Set and not support data reader

<< Previous Page 1 Page 2