ASP.NET Interview Questions and Answers (1544) - Page 1

What data types do the asp:RangeValidator control support?

NOTE: This is objective type question, Please click question title for correct answer.
What is ViewState?

ViewState allows the state of objects (serializable) to be stored in a hidden field on the page. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source. ViewState is used to retain the state of server-side objects between postabacks.
What is ASP.NET 2.0 Page Life Cycle?

Main Events
1. OnPreInit
2. OnInit
3. OnInitComplete
4. LoadViewState
5. OnPreLoad
6. OnLoad
7. RaisePostBackEvent
8. OnLoadComplete
9. OnPreRender
10. OnPreRenderComplete
11. SaveViewState
12. OnRender
13. OnUnload

Detailed Events
1. Constructor
2. Construct
3. TestDeviceFilter
4. AddParsedSubObject
5. DeterminePostBackMode
6. OnPreInit
7. LoadPersonalizationData
8. InitializeThemes
9. OnInit
10. ApplyControlSkin
11. ApplyPersonalization
12. OnInitComplete
13. LoadPageStateFromPersistenceMedium
14. LoadControlState
15. LoadViewState
16. ProcessPostData1
17. OnPreLoad
18. OnLoad
19. ProcessPostData2
20. RaiseChangedEvents
21. RaisePostBackEvent
22. OnLoadComplete
23. OnPreRender
24. OnPreRenderComplete
25. SavePersonalizationData
26. SaveControlState
27. SaveViewState
28. SavePageStateToPersistenceMedium
29. Render
30. OnUnload
What is difference between Trace and Debug?

Use Debug class to debug builds
Use Trace class for both debug and release builds.
Difference between DataSet and DataReader

DataReader is like a forward only recordset. It fetches one row at a time so very less network cost compare to DataSet(Fethces all the rows at a time). DataReader is readonly so we can't do any transaction on them. DataReader will be the best choice where we need to show the data to the user which requires no transaction. As DataReader is forward only so we can't fetch data randomly. .NET Data Providers optimizes the datareader to handle huge amount of data.

DataSet is an in memory representation of a collection of Database objects including tables of a relational database schemas.
DataSet is always a bulky object that requires a lot of memory space compare to DataReader. We can say that the DataSet is a small database because it stores the schema and data in the application memory area. DataSet fetches all data from the datasource at a time to its memory area. So we can traverse through the object to get the required data like querying database.
What is custom tag in web.config file?

Custom tag allows you to create your own tag and specify key value pair for it.
Which is stateless

NOTE: This is objective type question, Please click question title for correct answer.
How can you manage client-side state?

NOTE: This is objective type question, Please click question title for correct answer.
How can you manage server-side state?

NOTE: This is objective type question, Please click question title for correct answer.
Types of Configuration files and their difference?

1. Application level config = Web.config.
2. Machine level config = Machine.config.
what is the control for which by default post back is enabled(true)

NOTE: This is objective type question, Please click question title for correct answer.
What is HttpHandler?

HttpHanlder is the low level Request and Response API to service incoming Http requests. All handlers implement the IHttpHandler interface. There is no need to use any extra namespace to use it as it contains in the System.Web namespace. Handlers are somewhat analogous to Internet Server Application Programming Interface (ISAPI) extensions.

Each incoming HTTP request received by ASP.NET is ultimately processed by a specific instance of a class that implements IHTTPHanlder. IHttpHanlderFactory provides the infrastructure that handles the actual resolution of URL requests to IHttpHanlder instances. In addition to the default IHttpHandlerFactory classes provided by ASP.NET, developers can optionally create and register factories to support rich request resolution.
What is EnableViewStateMAC?

When EnableViewStateMAC is true for a page, the encoded and encrypted viewstate is checked to verify that it has not been tempered with on the client machine.

A EnableViewStateMAC is encoded version of the hidden variable that a page's viewstate is persisted to when sent to the browser.
Explain what a diffgram is, and a good use for one?

The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. A good use is reading database data to an XML file to be sent to a Web Service.
What is the lifespan for items stored in ViewState?

Item stored in ViewState exist for the life of the current page. This includes postbacks (to the same page).
How to make sure that despite using validation control on your.aspx page, your page is valid? or how to validate the page in the server side?

use Page.IsValid method, this revalidate your data server side against each Validation control used.
How to copy items from one DropDownList control to another DropDownList control.

Write following coder

foreach (ListItem item in drop1.Items)

Where drop1 is the id of first DropDownList and drop2 is the id of second DropDownList control.
What is the difference between asp:Label and asp:Literal control?

asp:Label control
asp:Label control is used to write text on the page with different formatting options like bold, italic, underlined etc.
For more on asp:Label see

asp:Literal control
Literal control is used to write simple text on the page, you can use server side formatting options like bold, italic, underlined.
For more on asp:Literal see
How to improve performance of web page in

Minimize the use of ViewState, Session, Turn off tracing etc.

For more see
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories